使用连接

你可以使用上下文管理器打开连接(即从池中请求一个连接):

with engine.connect() as conn:
    result = conn.execute('SELECT price FROM products')
    for row in result:
        print('Price:', row['price'])

或者没有,但必须手动关闭:

conn = engine.connect()
result = conn.execute('SELECT price FROM products')
for row in result:
    print('Price:', row['price'])
conn.close()