Ejemplo n.º 1
0
from dbconn import Employees,Session

zhangsan=Employees(emp_id=1,name='张三',gender="男",phone='13311530548',email='*****@*****.**',dep_id=1)
lisi=Employees(emp_id=2,name='李四',gender="男",phone='13311530555',email='*****@*****.**',dep_id=2)
harry=Employees(emp_id=3,name='harry',gender="女",phone='13311530555',email='*****@*****.**',dep_id=3)
alice=Employees(emp_id=4,name='alice',gender="女",phone='13311530555',email='*****@*****.**',dep_id=4)

session=Session()
session.add_all([zhangsan,lisi,harry,alice])
session.commit()
session.close()

Ejemplo n.º 2
0
wj = Employees(
    emp_id=1,
    name='王俊',
    gender='男',
    phone='15678789090',
    email='*****@*****.**',
    dep_id=3
)
wwc = Employees(
    emp_id=2,
    name='吴伟超',
    gender='男',
    phone='13499887755',
    email='*****@*****.**',
    dep_id=3
)
dzj = Employees(
    emp_id=3, name='董枝俊', gender='男', phone='18900998877', email='*****@*****.**', dep_id=3
)
ltd = Employees(emp_id=4, name='李通达', gender='男', phone='13378904567', email='*****@*****.**', dep_id=2)
wxy = Employees(emp_id=5, name='王秀燕', gender='女', phone='15098765432', email='*****@*****.**', dep_id=2)
gq = Employees(emp_id=6, name='高琦', gender='女', phone='15876543212', email='*****@*****.**', dep_id=1)
wzf = Employees(emp_id=7, name='王召飞', gender='男', phone='15609871234', email='*****@*****.**', dep_id=1)
sy = Employees(emp_id=8, name='孙燕', gender='女', phone='18567895435', email='*****@*****.**', dep_id=4)
gpf = Employees(emp_id=9, name='高鹏飞', gender='男', phone='13566889900', email='*****@*****.**', dep_id=2)
emps = [wj, wwc, dzj, ltd, wxy, gq, wzf, sy, gpf]
session = Session()
session.add_all(emps)
session.commit()
session.close()
Ejemplo n.º 3
0
                 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()
Ejemplo n.º 4
0
               email='*****@*****.**',
               dep_id=2)
ds = Employees(emp_id=5,
               name='德斯',
               gender='男',
               phone='18923745193',
               email='*****@*****.**',
               dep_id=2)
nd = Employees(emp_id=6,
               name='牛顿',
               gender='女',
               phone='10438201348',
               email='*****@*****.**',
               dep_id=4)
te = Employees(emp_id=7,
               name='test',
               gender='fale',
               phone='12345678910',
               email='*****@*****.**',
               dep_id=1)
emps1 = [kellon, moly]
emps2 = [kn, ds, nd]

session = Session()
session.add(te)
session.add(xl)
session.add_all(emps1)
session.add_all(emps2)
session.commit()
session.close()
Ejemplo n.º 5
0
    dep_id=1
)
cyj = Employees(
    name='陈雅津',
    gender='女',
    birth_date='2000-1-15',
    phone='13367895432',
    email='*****@*****.**',
    dep_id=1
)
hjx = Employees(
    name='花俊秀',
    gender='男',
    birth_date='1999-3-10',
    phone='18812345678',
    email='*****@*****.**',
    dep_id='2'
)
htq = Employees(
    name='黄天强',
    gender='男',
    birth_date='1995-5-20',
    phone='15078986655',
    email='*****@*****.**',
    dep_id=3
)
session.add_all([wyc, cyj, hjx, htq])

session.commit()
session.close()
Ejemplo n.º 6
0
# hr = Departments(dep_id=1, dep_name='HR')
# session.add(hr)
# session.commit()
#####################################
# ops = Departments(dep_id=2, dep_name='运维部')
# dev = Departments(dep_id=3, dep_name='开发部')
# qs = Departments(dep_id=4, dep_name='测试部')
# fn = Departments(dep_name='财务部')   # sqlalchemy把主键设置为了自动增长
# session.add_all([ops, dev, qs, fn])
# session.commit()
#####################################
tc = Employees(emp_id=100, emp_name='田超', email='*****@*****.**', dep_id=1)
by = Employees(emp_id=101, emp_name='白宇', email='*****@*****.**', dep_id=2)
bss = Employees(emp_id=200, emp_name='白尚松', email='*****@*****.**', dep_id=2)
hdy = Employees(emp_id=201, emp_name='何东阳', email='*****@*****.**', dep_id=3)
fg = Employees(emp_id=300, emp_name='房果', email='*****@*****.**', dep_id=2)
wfh = Employees(emp_id=301, emp_name='巫菲红', email='*****@*****.**', dep_id=1)
fcw = Employees(emp_id=302, emp_name='冯翠雯', email='*****@*****.**', dep_id=4)
sz = Employees(emp_id=400, emp_name='孙正', email='*****@*****.**', dep_id=2)
zqh = Employees(emp_id=401, emp_name='章勤浩', email='*****@*****.**', dep_id=3)
cjl = Employees(emp_id=500, emp_name='陈佳乐', email='*****@*****.**', dep_id=5)
hpw = Employees(emp_id=600, emp_name='黄平武', email='*****@*****.**', dep_id=4)
bh = Employees(emp_id=700, emp_name='柏宏', email='*****@*****.**', dep_id=2)
tr = Employees(emp_id=800, emp_name='唐瑞', email='*****@*****.**', dep_id=5)
lj = Employees(emp_id=900, emp_name='鲁俊', email='*****@*****.**', dep_id=3)
session.add_all(
    [tc, by, bss, hdy, fg, wfh, fcw, sz, zqh, cjl, hpw, bh, tr, lj])
session.commit()

session.close()
Ejemplo n.º 7
0
user1 = Employees(emp_id=1,
                  emp_name="zs",
                  gender='man',
                  birth_date='2018-07-14',
                  phone='12345678901',
                  email="*****@*****.**",
                  dep_id=1)
user2 = Employees(emp_id=2,
                  emp_name="ls",
                  gender='man',
                  birth_date='2018-02-11',
                  phone='12345678902',
                  email="*****@*****.**",
                  dep_id=1)
user3 = Employees(emp_id=3,
                  emp_name="ww",
                  gender='man',
                  birth_date='2018-06-13',
                  phone='12345678901',
                  email="*****@*****.**",
                  dep_id=2)
user4 = Employees(emp_id=4,
                  emp_name="zl",
                  gender='man',
                  birth_date='2018-04-14',
                  phone='12345678901',
                  email="*****@*****.**",
                  dep_id=2)
session.add_all([user1, user2, user3, user4])
session.commit()
session.close()
Ejemplo n.º 8
0
# wjg = (10, '王建港', 'man', '*****@*****.**',      '18299984673', 2)
# xr  = (11, '谢瑞', 'man', '*****@*****.**',    '15288825455', 2)
# ywj = (12, '严文杰', 'man', '*****@*****.**',  '15645672589', 2)
# xsh = (13, '肖书恒', 'man', '*****@*****.**', '12487545552', 2)
# lx  = (14, '刘鑫', 'waman', '*****@*****.**',  '13856942135', 1)

wjg = Employees(emp_id=11, emp_name='王建港', gender='man', phone='18299984673', dep_id=2)
xr = Employees(emp_id=12, emp_name='谢瑞', gender='man', phone='15288825455', dep_id=2)
ywj = Employees(emp_id=13, emp_name='严文杰', gender='man', phone='15645672589', dep_id=2)
xsh = Employees(emp_id=14, emp_name='肖书恒', gender='man', phone='12487545552', dep_id=2)
lx = Employees(emp_id=15, emp_name='刘鑫', gender='waman', phone='13856942135', dep_id=1)


# session.add(hr)
# session.add_all([op, dev, qa])
session.add_all([wjg, ywj, xr, xsh, lx])
session.commit()
session.close()


from dbconn import Departments, Session, Employees

session = Session()

# hr = Departments(dep_id=1, dep_name='hr')
# op = Departments(dep_id=2, dep_name='运维部')
# dev = Departments(dep_id=3, dep_name='开发部')
# qa = Departments(dep_id=4, dep_name='测试部')
# session.add(hr)
# session.add_all([op, dev, qa])
########################
Ejemplo n.º 9
0
#!/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()
Ejemplo n.º 10
0
from dbconn import Departments, Session

session = Session()
# sqlalchemy的主键默认设置为自动增长
# dev = Departments(dep_name="development")
# print(dev.dep_name)
# print(dev.dep_id)
# hr = Departments(dep_id=2, dep_name='人事部')
# session.add(hr)
ops = Departments(dep_name='运维部')
finance = Departments(dep_name='财务部')
session.add_all([ops, finance])
session.commit()
session.close()
Ejemplo n.º 11
0
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()
Ejemplo n.º 12
0
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()
Ejemplo n.º 13
0
#     empno=1014, ename='黄盖', job='文员', mgr=1007,
#     hiredate='2002-1-23',sal=13000.00,deptno=10,
# )
#
# u13 = emp(
#     empno=1011, ename='周泰', job='文员', mgr=1008,
#     hiredate='2007-5-23',sal=11000.00,deptno=20,
# )
#
# session.add_all([u1, u2, u3, u4, u5, u6, u7, u8, u9, u10, u11, u12, u13])

s1 = Students(name='张小明', chinese=89, english=98, math=90)
s2 = Students(name='李进', chinese=67, english=98, math=89)
s3 = Students(name='王五', chinese=87, english=78, math=77)
s4 = Students(name='李一', chinese=88, english=98, math=90)
s5 = Students(name='李来财', chinese=82, english=84, math=67)
s6 = Students(name='张进宝', chinese=55, english=85, math=45)
s7 = Students(name='黄蓉', chinese=85, english=75, math=80)
s8 = Students(name='张一李', chinese=75, english=65, math=30)
s9 = Students(name='何李', chinese=75, english=65, math=90)
s10 = Students(name='单', chinese=75, english=65, math=30)
s11 = Students(name='jack', chinese=75, english=65, math=40)
s12 = Students(name='marry', chinese=75, english=65, math=60)
session.add_all([s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12])

# 确认
session.commit()

# 关闭
session.close()
Ejemplo n.º 14
0
from dbconn import Departments, Employees, Salary, Session

# 创建会话实例,用于连接数据库
session = Session()

# 创建部门实例
hr = Departments(dep_id=1, dep_name='人事部')
ops = Departments(dep_id=2, dep_name='运维部')
dev = Departments(dep_id=3, dep_name='开发部')
qa = Departments(dep_id=4, dep_name='测试部')
finance = Departments(dep_id=5, dep_name='财务部')
market = Departments(dep_id=6, dep_name='市场部')
sales = Departments(dep_id=7, dep_name='销售部')

# 在数据库中创建记录
deps = [hr, ops, dev, qa, finance, market, sales]
session.add_all(deps)
session.commit()        # 确认至数据库

# 关闭会话
session.close()
Ejemplo n.º 15
0
# market = Department(dep_id=6,dep_name='市场部')
#
# # add data into biao
# session.add_all([hr,finance,ops,dev,qa,market])

# 创建员工
jax = Employees(emp_id=1,
                emp_name='贾克斯',
                birth_date='1986-6-6',
                email='*****@*****.**',
                dep_id=1)
js = Employees(emp_id=2,
               emp_name='剑圣',
               birth_date='1988-10-6',
               email='*****@*****.**',
               dep_id=2)
gl = Employees(emp_id=3,
               emp_name='盖伦',
               birth_date='1989-3-6',
               email='*****@*****.**',
               dep_id=3)
zx = Employees(emp_id=4,
               emp_name='赵信',
               birth_date='1990-6-6',
               email='*****@*****.**',
               dep_id=4)

session.add_all([jax, js, gl, zx])

session.commit()
session.close()
Ejemplo n.º 16
0
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
from dbconn import Departments, Session, Employees, Salary

session = Session()  #创建session会话
dev = Departments(dep_name='development')
print(dev.dep_name)
print(dev.dep_id)
dev = Departments(dep_name="人事部", dep_id=2)
session.add(dev)  #添加一个
ops = Departments(dep_name="运维部")
finance = Departments(dep_name="财务部")

session.add_all([ops, finance])  #添加多个
session.commit()
#print(dev.dep_id)
session.close()
Ejemplo n.º 17
0
# crud: 增删改查。create/retrieve/update/delete
from dbconn import Session, Departments, Employees

# 建立到数据库的会话连接
session = Session()

# 创建部门
hr = Departments(dep_id=1, dep_name='人事部')
ops = Departments(dep_id=2, dep_name='运维部')
dev = Departments(dep_id=3, dep_name='开发部')
qa = Departments(dep_id=4, dep_name='测试部')
market = Departments(dep_id=5, dep_name='市场部')
sales = Departments(dep_id=6, dep_name='销售部')

# 通过会话操作数据库
session.add_all([hr, ops, dev, qa, market, sales])

# 确认
session.commit()

# 关闭会话
session.close()