【发布时间】:2012-06-28 15:35:45
【问题描述】:
这段python代码应该在数据库上运行语句,但是sql语句没有执行:
from sqlalchemy import *
sql_file = open("test.sql","r")
sql_query = sql_file.read()
sql_file.close()
engine = create_engine(
'postgresql+psycopg2://user:password@localhost/test', echo=False)
conn = engine.connect()
print sql_query
result = conn.execute(sql_query)
conn.close()
test.sql 文件包含创建 89 个表的 SQL 语句。
如果我指定 89 个表,则不会创建表,但如果我将表数减少到 2 个,则它可以工作。
conn.execute 中可以执行的查询数量是否有限制?如何运行任意数量的这样的原始查询?
【问题讨论】:
-
好像你没有提交你的创建表。
标签: python postgresql sqlalchemy