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!
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.
run it directly as a console or import it as a module
- 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
the function from() in CodeIgniter is renamed to table() as 'from' is a key word in python.
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()
please visit the CodeIgniter activerecord user guide.