Lorm: A light weight mysql client library.
Lorm is a light weight mysql client library for Python. Built-in connection pool, Django style lookup expressions.
Installation
The last stable release is available on PyPI and can be installed with pip:
$ pip install lorm
Example
CREATE TABLE `pets` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL DEFAULT '',
`add_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Connect to Mysql
>>> import pymysql
>>> import lorm
>>> db = lorm.Hub(pymysql)
>>> db.add_pool('default', host='localhost', port=3306, user='root',
passwd='root', db='test', autocommit=True, pool_size=8, wait_timeout=30)
Insert
>>> db.default.pets.create(name='cat')
1
Query
>>> db.default.pets.get(id=1)
{u'id': 2, u'name': u'cat'}
Row Style
>>> db.default.pets.filter(id__lt=10).select('id')[:]
[{u'id': 1}, {u'id': 2}, {u'id': 4}, {u'id': 5}, {u'id': 6}, {u'id': 7}, {u'id': 8}, {u'id': 9}]
>>> db.default.pets.filter(id__lt=10).values('id')[:]
((1,), (2,), (4,), (5,), (6,), (7,), (8,), (9,))
>>> db.default.pets.filter(id__lt=10).flat('id')[:]
[1, 2, 4, 5, 6, 7, 8, 9]
Raw SQL
>>> db.default.fetchall("select * from pets")
((1, u'cat'), (2, u'dog'), (3, u'bird'))
Transaction
>>> with db.default as c:
>>> print c.pets.create(name='fish')
For more examples, see example.py
Features
Built-in Connection pool
Django style lookup expressions
Concurrent safe
Gevent friendly
Dynamically driver
Metadata
Release files for lorm 1.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lorm-1.0.12.tar.gz | 9.6 kB | Details |
Release files / lorm-1.0.12.tar.gz
| Download URL | lorm-1.0.12.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
48b4fc09611abcdb9f0a3679b36753520eac1506a7ab7a1709fc0e8b6d536a92
|
|
BLAKE2b-256 checksum How to use checksums |
8278d5c9a66579b02f0aacd5c1a4274e1baca67643edf302bdae50fee589db26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/2.7
|