from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
engine = create_engine('postgresql+psycopg2://nocilantro:123456@localhost:5432/test_db')
DB_Session = sessionmaker(bind=engine)
session = DB_Session()
res = session.execute("SELECT * FROM test_table")
for row in res:
print(row)
session.commit()
session.close()
"""
('香菜', '啊哈')
('nocilantro', '不要香菜')
('gaigai', '盖盖')
"""