SQLAlchemy Layer - SQL Expression 说明

请添加图片描述

Expressions let you compose SQL statements by building Python objects.

  • Instead of sending raw SQL (using the Engine), we can compose python objects to compose SQL expressions, instead.
  • SQL Expressions still involves using the knowing SQL to interact with the database.
todos = Table('todos',...)

ins = todos.insert().values(
	description = 'Clean my room',
	completed = False
)

s = select([todos])

conn = engine.connect()
result = conn.execute(ins)
result = conn.execute(s)

result.close()

猜你喜欢

转载自blog.csdn.net/BSCHN123/article/details/121220164