如何停止sqlalchemy查看“绑定参数”在现有的模式中(对于Tusker)

发布于 2025-01-31 18:48:14 字数 782 浏览 5 评论 0原文

我正在尝试使用Tusker比较模式版本,并检查当前数据库是一致的。

我的架构文件包含用于数据库定义的RAW SQL,包括PLPGSQL函数,其中之一是行:

json = '{ "type": "Category", "data": {"empty":0} }';

此架构文件设计用于直接导入到PSQL中,并且按原样工作正常。

但是,我现在正在尝试使用Tusker和Sqlalchemy Barfs处理架构管理工具,当它试图运行时:

sql = sqlalchemy.text(sql)
cursor.execute(sql)

抱怨:

Error executing SQL file schema_functions.sql: (sqlalchemy.exc.InvalidRequestError) A value is required for bind parameter '0' 

我无法修改架构文件(否则,这是添加逃生字符的琐事,但是然后它将在PSQL中破裂); 因此,有什么方法可以告诉Sqlalchemy“不将整数解释为绑定参数”?

有关更多信息,请参见: https://github.com/bikeshedder/tusker/tusker/tusker/18

I am trying to use Tusker to compare schema versions and check the current database is consistent.

My schema file contains raw SQL for database definitions, including plpgsql functions, in one of which is the line:

json = '{ "type": "Category", "data": {"empty":0} }';

This schema file is designed for direct import into psql, and works fine as is.

However, I'm now trying to deal with the schema-management tool using tusker and SQLAlchemy barfs, when it tries to run:

sql = sqlalchemy.text(sql)
cursor.execute(sql)

complaining:

Error executing SQL file schema_functions.sql: (sqlalchemy.exc.InvalidRequestError) A value is required for bind parameter '0' 

I can't modify the schema file (otherwise this would be trivial to add an escape character, but then it will break in psql);
So, is there any way to tell sqlalchemy to "not interpret integers as bind parameters"?

For more see: https://github.com/bikeshedder/tusker/issues/18

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文