from sqlalchemy import create_engine 執行SQL語句(增刪改查均可)

舉例:刪除一條記錄

from sqlalchemy import create_engine

host = '10.x.x.x'
user = 'xxxx'
password = 'xxxxx'
port = 'xxx'
database = 'xxxx'
engine_str = 'postgres://' + user + ':' + password + '@' + host + ':' + port + '/' + database
conn = create_engine(engine_str)
sql = "delete  FROM aaa_test_ma_biao where 序列號='FCQ1544Y4PS'"
conn.execute(sql)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章