SQLAlchemy连接Postgresql(执行原生sql)
2020-05-08 本文已影响0人
一杯海风_3163
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)