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으로 배우는 데이터베이스 입문