Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pony.orm import *
- db=Database()
- class Admin(db.Entity):
- ime=Required(str)
- prezime=Required(str)
- email=Required(str)
- password=Required(str)
- class SalterRadnik(db.Entity):
- ime=Required(str)
- prezime=Required(str)
- email=Required(str)
- password=Required(str)
- class Student(db.Entity):
- ime = Required(str)
- prezime= Required(str)
- email= Required(str)
- password= Required(str)
- budzet= Required(int)
- racun= Required(int)
- predmeti = Optional("Slusa")
- class Predmet(db.Entity):
- naziv=Required(str)
- studenti=Optional("Slusa")
- class Slusa(db.Entity):
- student=Required(Student)
- predmet=Required(Predmet)
- PrimaryKey(student,predmet)
- ispit=Optional("Ispit")
- class Rok(db.Entity):
- naziv=Required(str)
- ispit=Optional("Ispit")
- class Ispit(db.Entity):
- slusa=Required(Slusa)
- rok=Required(Rok)
- PrimaryKey(slusa,rok)
- ocena=Required(int)
- datum=Required(str)
- db.bind('mysql', host='localhost', user='python', passwd='python', db='python')
- db.generate_mapping(create_tables=True)
- # s=Student(ime='ime!',prezime='prezime',email='mail',password='sadasd',budzet=1,racun=21121)
- # p=Predmet(naziv='sssass')
- @db_session
- def print_person_name(x):
- p=Predmet(naziv=x)
- s=Student(ime='iame',prezime='prezime!!!!!',email='mail',password='sadasd',budzet=1,racun=21121)
- sl=Slusa(student=s,predmet=p)
- commit()
- print_person_name("peraaa")
- def logged(id):
- with db_session:
- s=select(s for s in Student if 1==s.id)[:]
- return s[0]
- s=logged(1)
- @db_session
- def insertStudent(newStud):
- s=Student(ime=newStud[0],prezime='ssss',email='mail',password='sadasd',budzet=1,racun=21121)
- commit()
- @db_session
- def findByID(id):
- with db_session:
- s=select(s for s in Student if id==s.id)[:]
- return s[0]
- @db_session
- def updateStudent(id,toUpdate):
- s=findByID(id)
- s.ime=toUpdate[0]
- s.prezime=toUpdate[1]
- s.email=toUpdate[2]
- s.password=toUpdate[3]
- s.budzet=toUpdate[4]
- s.racun=toUpdate[5]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement