SQLAlchemy - 用于测试的 SQLite 和用于开发的 Postgresql - 如何移植?

2021-12-30 00:00:00 python postgresql sqlalchemy sqlite

我想在我的所有测试中使用 sqlite 内存数据库,在我的开发/生产服务器上使用 Postgresql.

I want to use sqlite memory database for all my testing and Postgresql for my development/production server.

但是两个数据库中的 SQL 语法并不相同.例如:SQLite 有自动增量,而 Postgresql 有串行

But the SQL syntax is not same in both dbs. for ex: SQLite has autoincrement, and Postgresql has serial

将 SQL 脚本从 sqlite 移植到 postgresql 是否容易...您的解决方案是什么?

Is it easy to port the SQL script from sqlite to postgresql... what are your solutions?

如果您要我使用标准 SQL,我应该如何在两个数据库中生成主键?

If you want me to use standard SQL, how should I go about generating primary key in both the databases?

推荐答案

不要这样做.不要在一种环境中测试并在另一种环境中发布和开发.您使用此流程要求有错误的软件.

Don't do it. Don't test in one environment and release and develop in another. Your asking for buggy software using this process.

相关文章