Python SQLite Object-Relational Mapper
' ________ ________ ___ ________ ________ _____ ______
' |\ ____\|\ __ \|\ \ |\ __ \|\ __ \|\ _ \ _ \
' \ \ \___|\ \ \|\ \ \ \ \ \ \|\ \ \ \|\ \ \ \\\__\ \ \
' \ \_____ \ \ \\\ \ \ \ \ \ \\\ \ \ _ _\ \ \\|__| \ \
' \|____|\ \ \ \\\ \ \ \____\ \ \\\ \ \ \\ \\ \ \ \ \ \
' ____\_\ \ \_____ \ \_______\ \_______\ \__\\ _\\ \__\ \ \__\
' |\_________\|___| \__\|_______|\|_______|\|__|\|__|\|__| \|__|
' \|_________| \|__|
'
'
SQL-ORM Is a Python Object Relational Mapper for SQLite3. With These Script, We Can Use Python SQLite API Very Easly.
-
Easy To Use
-
Easy To Maintain
-
Can Access More Than One Database At a Time.
-
Can Access More Than One Table At a Time.
-
Can Access More Than One Row At a Time.
-
No External Dependencies
- Import Module Content.
# Import Module
from sqlorm import Field, Model
- Define Model Structure.
# Creating A Database Models Structure
class TestingDataBase(Model):
# Creating New Table. Name="AboutTeachers"
class AboutTeachers:
# Creating 4 Columns. Name = Name, Age, Income, Phone
#
#Columns Datatype
Name = Field.String
Age = Field.Integer
Income = Field.Integer
Phone = Field.LongInt
#
class AboutBooks:
# Creating 4 Columns. Name = Name, Price, Class
#
# Columns DataType
Name = Field.String
Price = Field.Integer
Class = Field.String
#
- Read Comments
# Create Object For InterFace
DBase = TestingDataBase()
# Connect To DataBase
DBase.connect(dbname="Testing_DataBase")
# or Use Only DBase.connect()
# Get All Available Tables Names as list
print DBase.get_all_tables_name()
# Get All Columns Names From Tables
for table in DBase.get_all_tables_name():
print "\nTable Name : {}\n".format(table)
print DBase.get_all_columns_(table) # As List
# Get All Tables With Interface Object In Dictionery
print DBase.get_tables()
# Default Database Name
print DBase.get_db_names()
# Get Table Interface
t = DBase.Table(name="AboutTeachers")
# or
t = DBase.get_tables()["AboutTeachers"]
# Create New Row Interface
n = t.new()
# Set New Values Using set_all
n.set_all(Age=10, Income = 45000, Name = "Sam")
# Get All Values as Dictionery
print n.get_all()
# Save Row InterFace
n.save()
# Get Row Interface
r = t.get(id)
# Close database
DBase.save()
######################################################
By S.S.B Group
######################################################
Suraj Singh
Admin
S.S.B Group
surajsinghbisht054@gmail.com
http://bitforestinfo.blogspot.com/
Note: We Feel Proud To Be Indian
######################################################
Want to Contribute? Great!
There Are 2 Methods.
-
Pull Request ( Github Account Required ).
-
Through Email.
-
Fork it!
-
Create your feature branch:
git checkout -b my-new-feature
-
Commit your changes:
git commit -am 'Add some feature'
-
Push to the branch:
git push origin my-new-feature
-
Submit a pull request :D
- Send Your Updated Version On My Email.
See CONTRIBUTING.
Apache License