from dbconn import Session, Salary aug2018 = Salary(date='2018-8-10', emp_id=1, basic=10000, awards=2000) session = Session() session.add(aug2018) session.commit() session.close()
# session.add(dep_fn) wh = Employee( emp_name='王贺', gender='male', birth_date='1993-1-1', phone='17788990022', email='*****@*****.**', dep_id=1 ) lj = Employee( emp_name='李俊', gender='male', birth_date='1995-10-1', phone='13355667788', email='*****@*****.**', dep_id=4 ) zzh = Employee( emp_name='赵子浩', gender='male', birth_date='1999-5-4', phone='13556789987', email='*****@*****.**', dep_id=4 ) # session.add_all([wh, lj, zzh]) wh20181001 = Salary(emp_id=1, date='2018-10-01', basic=15000, awards=5000) session.add(wh20181001) session.commit() session.close()
email='*****@*****.**', dep_id='1') alice = Employees(emp_id=3, emp_name='Alice', gender='female', birth_date='1997-02-2', email='*****@*****.**', dep_id='2') jane = Employees(emp_id=4, emp_name='Jane', gender='female', birth_date='1988-09-23', email='*****@*****.**', dep_id='2') tom = Employees(emp_id=5, emp_name='Tom', gender='male', birth_date='1994-04-6', email='*****@*****.**', dep_id='3') session = Session() session.add_all([bob, john, alice, jane, tom]) ##向salary表添加内容 aug2018 = Salary(date='2018-8-11', emp_id=1, basic=12000, awards=3000) session = Session() session.add(aug2018) session.commit() session.close()
#!/usr/bin/env python3 # _*_coding:utf8_*_ from dbconn import Salary, Session jian2018_10 = Salary(date='2018-1-10', emp_id=1, basic=15000, awards=3000) jian2018_11 = Salary(date='2018-1-11', emp_id=1, basic=26000, awards=8000) moly2018_10 = Salary(date='2018-1-10', emp_id=2, basic=28000, awards=10000) moly2018_11 = Salary(date='2018-1-11', emp_id=2, basic=36000, awards=8000) jian = [jian2018_11, jian2018_10] moly = [moly2018_10, moly2018_11] session = Session() session.add_all(jian) session.add_all(moly) session.commit() session.close()
from dbconn import Salary,Session zhangsan=Salary(auto_id=1,emp_id=1,date='2018-07-30',basic=5000,awards=1050) lisi=Salary(auto_id=2,emp_id=2,date='2018-07-30',basic=5000,awards=1050) session=Session() session.add_all([zhangsan,lisi]) session.commit() session.close()
from dbconn import Salary, Session jan2018_1 = Salary(date='2018-01-10', emp_id=1, basic=10000, awards=2000) jan2018_2 = Salary(date='2018-01-10', emp_id=2, basic=11000, awards=1500) jan2018_3 = Salary(date='2018-01-10', emp_id=3, basic=11000, awards=2200) jan2018_4 = Salary(date='2018-01-10', emp_id=4, basic=11000, awards=3000) jan2018_5 = Salary(date='2018-01-10', emp_id=1, basic=13000, awards=2000) jan2018_6 = Salary(date='2018-01-10', emp_id=6, basic=15000, awards=3000) jan2018_7 = Salary(date='2018-01-10', emp_id=7, basic=9000, awards=3000) jan2018_8 = Salary(date='2018-01-10', emp_id=8, basic=13000, awards=2000) jan2018_9 = Salary(date='2018-01-10', emp_id=9, basic=13000, awards=1500) session = Session() sals = [ jan2018_1, jan2018_2, jan2018_3, jan2018_4, jan2018_5, jan2018_6, jan2018_7, jan2018_8, jan2018_9 ] session.add_all(sals) session.commit() session.close()
from dbconn import Employees, Departments, Salary, Session # 创建会话实例,用于连接数据库 session = Session() # 创建员工实例 gz1 = Salary( id = 1, date = '2019-06-10', emp_id = 1, basic = 8000, awards = 2000, ) gz2 = Salary( id = 2, date = '2019-06-10', emp_id = 2, basic = 8000, awards = 2000, ) gz3 = Salary( id = 3, date = '2019-06-10', emp_id = 3, basic = 8000, awards = 1555, ) gz4 = Salary( id = 4, date = '2019-06-10', emp_id = 4,