Paull / python-mysql-orm

a Mysql orm/query builder Python module. Operate in CodeIgniter activerecord style

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This a Mysql orm/query builder Python module in CodeIgniter activerecord style.

It is designed for personal projects and has been tested in production environments, running steady, for years.

If you found any bugs or have any suggestions, do not hesitate to let me know, I will do my best to fix them. And you are welcome to make it better!


Python Mysql Active Record

This is an activerecord module inspired by CodeIgniter activerecord and its database driver library.

Interacting with mysql in CodeIgniter way that you can do CURD like a pro in your python application.

Dependency

Usage

run it directly as a console or import it as a module

screenshot

  • 1.first of all, you have to configure your database in config.py
  • 2.1 import the database module then follow the step3 and step4
  • 2.2 or just run database.py as a console then follow step4
  • 3.make a instance of the class to initialize a database connection: db = Database()
  • 4.call functions just like we do in codeigniter

Notice

the function from() in CodeIgniter is renamed to table() as 'from' is a key word in python.

Examples

run an instance

import Database from database
db = db = Database()
dating_target = db.table('employee').select('firstname, lastname, email, mobile').where('age <', 25).where('gender', 'female').order_by('age', 'asc').limit(10, 20).get().result()
print dating_target

or run database.py directly as a console

db.talbe('employee')
db.where({'firstname':'Paul', 'age >': 28})
db.get()
print db.row()

More Help

please visit the CodeIgniter activerecord user guide.

About

a Mysql orm/query builder Python module. Operate in CodeIgniter activerecord style


Languages

Language:Python 100.0%