This repository has been archived by the owner. It is now read-only.
fysql is a small ORM inpired by peewee. This project is dead for now - I'll publish a new version in January 2019
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
.gitignore
LICENSE
Makefile
README.rst
columns.py
containers.py
databases.py
entities.py
exceptions.py
flask_fysql_example.py
requirements.txt
requirements.txt.bkp
setup.py
static.py
tables.py
utils.py

README.rst

fysql

This project is dead for now - I'll publish a new version in January 2019 Still in developpement

fysql is a small python ORM inpired by peewee.

Have fun

Definition of your tables.

from fysql import *

database = MySQLDatabase('db', host='localhost', user='x', passwd='x')

class User(Table):
    firstname = CharColumn(max_length=50)
    lastname  = CharColumn(max_length=50)
    role      = CharColumn(index=True, unique=True)

User.create_table()

Creating your first User.

>>> user = User.create(firstname='Fy', lastname='SQL', role='Admin')
>>> print user
{"id": 1, "lastname": "SQL", "role": "Admin", "firstname": "Fy"}

Updating your User.

>>> user.role = 'Member'
>>> user.save()
>>> print user
{"id": 1, "lastname": "SQL", "role": "Member", "firstname": "Fy"}

Selecting one User.

>>> user = User.get(User.id==1)
>>> print user
{"id": 1, "lastname": "SQL", "role": "Admin", "firstname": "Fy"}

Adding new users and selecting members.

>>> User.create(firstname='Jean', lastname='Bon', role='Member')
>>> User.create(firstname='Jean', lastname='Rhume', role='Admin')
>>> users = User.filter(User.role=='Member').all()
>>> print users
[{"id": 1, "lastname": "SQL", "role": "Member", "firstname": "Fy"}, {"id": 2, "lastname": "Bon", "role": "Member", "firstname": "Jean"}]

Counting users.

>>> count_users = User.count_filter(User.role <<< ['Member', 'Admin'])
>>> print count_users
3