【发布时间】:2014-03-08 20:25:29
【问题描述】:
当使用带有多种方言的 sqlalchemy 时,仅添加特定方言的配置,例如 sqlite's foreign key support 或 postgres 的 server_side_cursors 会产生问题,因为所有其他方言都不会理解配置或事件。例如:
# applying postgres configuration to a sqlite3 database fails
>>> sqlalchemy.create_engine("sqlite3:///test.sqlite3", server_side_cursors=True)
...
TypeError: Invalid argument(s) 'server_side_cursors' sent to create_engine(), using configuration SQLiteDialect_pysqlite/NullPool/Engine. Please check that the keyword arguments are appropriate for this combination of components.
但是,sqlite 不需要此配置,因为它会自动流式传输结果。同样,postgres 不需要启用外键支持,因为这是默认设置。
如何以不破坏其他方言的方式应用这种特定于方言的配置?是否有一些 sqlalchemy 促进了这种分支?还有比isinstance 测试更好的东西吗?
【问题讨论】:
标签: sqlalchemy