美文网首页
SQLAlchemy连接Postgresql(执行原生sql)

SQLAlchemy连接Postgresql(执行原生sql)

作者: 一杯海风_3163 | 来源:发表于2020-05-08 19:08 被阅读0次
from sqlalchery import create_engine
engine = create_enging('postgresql://username:password@IP:port/database_name',echo=True)

db_conn = engine.connect()
sql = '''  
         DROP table if exists test_tabel;
         create table test_table(colum1,colum2,colum3)...
'''
db_conn.execute(sql)

相关文章

网友评论

      本文标题:SQLAlchemy连接Postgresql(执行原生sql)

      本文链接:https://www.haomeiwen.com/subject/qtvxnhtx.html