英文:
SQLAlchemy sqlite create_engine throws an exception
问题
我在我的单元测试中使用了一个SQLite数据库,最近尝试升级到SQLAlchemy的2.0.4版本,但这导致了创建测试SQLite数据库的问题:
engine = sa.create_engine('sqlite://')
sqlalchemy_connection = engine.connect()
dbapi_connection = <sqlite3.Connection object at 0x7f9ea0ba6570>
def set_regexp(dbapi_connection):
dbapi_connection.create_function(
"regexp", 2, regexp, **create_func_kw
)
E TypeError: 函数最多接受3个参数(提供了4个)
在1.4.16版本下运行正常,有人有任何想法吗?(看起来问题出在create_engine上,但与迁移指南中的示例类似)
英文:
I use an sqlite db for my unittests and tried to update to the 2.0.4 version of SQLAlchemy recently and this leads to an issue with creating a test sqlite DB:
engine = sa.create_engine('sqlite://')
sqlalchemy_connection = engine.connect()
dbapi_connection = <sqlite3.Connection object at 0x7f9ea0ba6570>
def set_regexp(dbapi_connection):
> dbapi_connection.create_function(
"regexp", 2, regexp, **create_func_kw
)
E TypeError: function takes at most 3 arguments (4 given)
Works fine with 1.4.16, anyone got any ideas? (the create_engine semms to be at fault, but looks similar to the examples in the migration guide)
答案1
得分: 0
这确实是一个较旧的sqlite版本(例如,与rhel 7捆绑使用的版本)与SQLAlchemy 2.0不兼容的问题。有关完整讨论,请参见:https://github.com/sqlalchemy/sqlalchemy/discussions/9379
英文:
This is indeed an incompatibility issue of a quite old sqlite version (shipped with rhel 7 for example) and sqlalchemy 2.0, for the complete discussion, see: https://github.com/sqlalchemy/sqlalchemy/discussions/9379
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论