1 / 13

YAOP

Group P06: Chen Xi Han Lin Hu Qiang Xie Chenhong. YAOP. Yet Another ORM in Python. Introduction. YAOP is: A set of Python API Serialization of objects into SQLite3 Object Oriented Easy to use. Architecture. Data Definition Language Data Manipulation Language. Architecture Diagrams.

hanley
Download Presentation

YAOP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Group P06: Chen Xi Han Lin Hu Qiang Xie Chenhong YAOP Yet Another ORM in Python

  2. Introduction • YAOP is: • A set of Python API • Serialization of objects into SQLite3 • Object Oriented • Easy to use

  3. Architecture • Data Definition Language • Data Manipulation Language

  4. Architecture Diagrams

  5. Data Definition Language • Table Creation • … in an OOP manner

  6. Table Creation >>> ah_beh = Student(name="Ah Beh", age=15) >>> dog_lover1 = Person(name="John") Student and Person table will be created. >>> dog_lover2 = Person(name="Alex") Person table has already been created, no repeated creation.

  7. Kicking in OOP >>> class Kid(Person): age = Attribute(str) Kid inherit from Person so it has both name and the additional attribute - age.

  8. Data Manipulation Language • Creation • Read/Search • Update • Delete

  9. Creation >>> ah_beh = Student(name="Ah Beh", age=15) >>> ah_beh.update(grade=5) >>> print ah_beh.save() >>> Executed: insert into Student(grade,age,name) values(5,15,"Ah Beh")

  10. Read/Search >>> pets_named_bobby = Pet.search(name="Bobby") >>> one_of_bobbies = pets_named_bobby[0] >>> # Check if this is John's Bobby >>> if one_of_bobbies.owner.value == johns_id: print "John finds his Bobby" else: print "This is not John's Bobby" >>> John finds his Bobby

  11. Update >>> ah_beh.update(grade=6) # Level up >>> ah_beh.save() >>> print ah_beh.grade.value >>> Executed: update Student set grade=6,age=15,name="Ah Beh" where id=1

  12. Delete >>> ah_beh.remove() >>> one_of_bobbies.remove() >>> dog_lover.remove()

  13. Q & A Thank you

More Related