-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
61 lines (48 loc) · 1.57 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from database import sesija, Employee, Product, Sale
def insert_employee(session, full_name, email, age, position, salary, years_in_company):
emp1 = Employee(full_name = "File Tom",
email = "[email protected]",
age = 60,
position = 'technical support',
salary = 75000,
years_in_company = 15)
sesija.add(emp1)
sesija.commit() # commit izvrsuva
print(f"Vraboteniot {full_name} e vnesen! ")
return emp1
def insert_product(sesija, name, price):
prod1 = Product(name = name,price= price )
sesija.add(prod1)
sesija.commit()
print(f"Produktot: {name} e dodaden ")
return prod1
def insert_sale(sesija, employee_id, product_id):
sale1 = Sale(employee_id = employee_id, product_id=product_id)
sesija.add(sale1)
sesija.commit()
print("Prodazbata e zabelezana. ")
return sale1
print("Novi promeni vo nov brach")
ime = input("Vnesete ime: ")
print(f"Zdravo {ime}")
'''
p = insert_product(sesija, 'banani', '100')
e = insert_employee(sesija, "Teo", '[email protected]', 25, 'software developer', 30000, 5)
# e i p se objekti
# debugger to check what the program is doing in the background
# F5 -> python debugger -> python file
s = insert_sale(sesija, 1, 1)'''
#########################################
## Zemanje podatoci
'''
#################### Update
'''
employees.salary = 80000
sesija.commit()'''
# filter by ID or full_name
###########################
# DELETE
'''
employee = sesija.query(Employee).filter_by(id=17).first()
sesija.delete(employee)
sesija.commit()'''