The full version of this documentation is at mosql.mosky.tw.
It lets you use the common Python data structures to build SQLs. Here are the main features:
- Easy-to-learn --- Everything is just a plain Python object or SQL keyword.
- Flexible --- The query it builds fully depends on the structure you provide.
- Secure --- It prevents the SQL injection from both identifier and value.
- Fast --- It simply translates the Python data structures into SQLs.
It is just more than SQL.
Here we have a dictionary which includes the information of a person:
>>> mosky = {
... 'person_id': 'mosky',
... 'name' : 'Mosky Liu',
... }
And we want to insert it into a table named person. It is easy with mosql.query:
>>> from mosql.query import insert
>>> print(insert('person', mosky))
INSERT INTO "person" ("person_id", "name") VALUES ('mosky', 'Mosky Liu')
Check The Common Queries — mosql.query for detail, or there are examples which interact with real database.
It is available on PyPI:
$ sudo pip install mosql
Or clone the source code from GitHub:
$ git clone git://github.com/moskytw/mosql.git