Python 中的数据库入门
Jason Myers
Co-Author of Essential SQLAlchemy and Software Engineer
insert() 语句insert() 的参数是要写入的表values 子句中以 列=值 成对提供要插入的值from sqlalchemy import insert
stmt = insert(employees).values(id=1,name='Jason', salary=1.00, active=True)result_proxy = connection.execute(stmt) print(result_proxy.rowcount)
1
stmt = insert(employees)values_list = [{'id': 2, 'name': 'Rebecca', 'salary': 2.00, 'active': True}, {'id': 3, 'name': 'Bob', 'salary': 0.00, 'active': False}]result_proxy = connection.execute(stmt, values_list)print(result_proxy.rowcount)
2
Python 中的数据库入门