具有SQLAlchemy,SQLite和Postgresql的架构合格表? [英] Schema qualified tables with SQLAlchemy, SQLite and Postgresql?

查看:86
本文介绍了具有SQLAlchemy,SQLite和Postgresql的架构合格表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Pylons项目和一个实现模式限定表的SQLAlchemy模型:

I have a Pylons project and a SQLAlchemy model that implements schema qualified tables:

class Hockey(Base):
    __tablename__ = "hockey"
    __table_args__ = {'schema':'winter'}
    hockey_id = sa.Column(sa.types.Integer, sa.Sequence('score_id_seq', optional=True), primary_key=True)
    baseball_id = sa.Column(sa.types.Integer, sa.ForeignKey('summer.baseball.baseball_id'))

此代码可与Postgresql配合使用,但在表名和外键名上使用SQLite时失败(由于SQLite缺乏模式支持)

This code works great with Postgresql but fails when using SQLite on table and foreign key names (due to SQLite's lack of schema support)

sqlalchemy.exc.OperationalError:(OperationalError)未知数据库 winter'PRAGMA winter .table_info(曲棍球)'()

sqlalchemy.exc.OperationalError: (OperationalError) unknown database "winter" 'PRAGMA "winter".table_info("hockey")' ()

I' d想继续使用SQLite进行开发和测试。

I'd like to continue using SQLite for dev and testing.

是否有办法使SQLite正常失败?

Is there a way of have this fail gracefully on SQLite?

推荐答案


我想继续为
dev和t使用SQLite

I'd like to continue using SQLite for dev and testing.

是否有办法在SQLite上使
正常失败?

Is there a way of have this fail gracefully on SQLite?

很难知道从哪里开始这样的问题。所以。

It's hard to know where to start with that kind of question. So . . .

停止。只需停止它即可。

Stop it. Just stop it.

有些开发人员没有在其目标平台上进行开发的奢侈品。他们的生活很艰辛-将代码(有时是编译器)从一种环境迁移到另一种环境,进行两次调试(有时必须在目标平台上进行远程调试),逐渐意识到他们的内心确实是

There are some developers who don't have the luxury of developing on their target platform. Their life is a hard one--moving code (and sometimes compilers) from one environment to the other, debugging twice (sometimes having to debug remotely on the target platform), gradually coming to an awareness that the gnawing in their gut is actually the start of an ulcer.

安装PostgreSQL。

Install PostgreSQL.

可以使用相同的数据库环境进行开发,测试和部署时,应该

When you can use the same database environment for development, testing, and deployment, you should.

更不用说质量检查团队了。他们到底为什么要测试他们将不发货的东西?如果您要在PostgreSQL上进行部署,请确保在PostgreSQL上的工作质量。

Not to mention the QA team. Why on earth are they testing stuff they're not going to ship? If you're deploying on PostgreSQL, assure the quality of your work on PostgreSQL.

严重。

这篇关于具有SQLAlchemy,SQLite和Postgresql的架构合格表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆