Skip to content

a python database helper to make the CRUD very easy ... Enjoy!

Notifications You must be signed in to change notification settings

ipansensoy/ZED-Python-database

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

The New Project

https://github.com/C0deBot/py-db-with-models

ZED-Python-database

a python database helper to make the CRUD very easy ... Enjoy!

Code Examples

you can get all data from a table using

#table method takes 1 param which is the name of the table
# the all() method doesn`t take any params
DB().table("table_name").all()

you can get some data from a table using

#where method takes only 2 params which is the column name and the value of it
DB().table("table_name").where('id',1).get()
#another example with or where
DB().table("table_name").where('id',1).orWhere('username','zed').get()
#another example with whereNot this will get all records which not equal this value
DB().table("table_name").whereNOT('id',1).get()

you can change the id with any col name

EXAMPLE WITH ORDER BY AND LIMIT

DB().table("table_name").where('name','zed').orderBy('id','desc').limit(5).get()

then you can use the result data from READ by for loop

##Example

users = DB().table("users").all()
for user in users:
  print(user)

you can insert data to database using dictionary like this

DB().table("table_name").create({"username":"zed","email":"zed@mail.com","password":"123456"})

also you can update data with dictionary

 DB().table("table_name").where('id',2).update({"username":"zed_magdy","password":"122222"})

you can delete a record by using the following method

  #find method takes 1 param wich is the "id"
  DB().table("table_name").find(1).delete()

Open Source for life <3

About

a python database helper to make the CRUD very easy ... Enjoy!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%