Skip to main content

A light weight python ORM without models.

Project description

https://img.shields.io/pypi/v/lorm.svg

Lorm is a light weight ORM library for Python, model-less, Django style lookup expressions. It’s suitable for small standalone database script.

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

>>> c = lorm.mysql_connect('localhost', 3306, 'root', 'root', 'test')

Insert

>>> c.pets.create(name='cat')
1

Query

>>> c.pets.get(id=1)
{u'id': 2, u'name': u'cat'}
>>> c.last_query
select * from pets where id=1 limit 1

Raw SQL

>>> c.fetchall("select * from pets")
((1, u'cat'), (2, u'dog'), (3, u'bird'))

For more examples, see test.py

Features

  • No Model, use table name directly.

  • Auto reconnect

  • Connection pool

  • Django style lookup expressions

  • Threading safe

Requirements

  • pymysql

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lorm-0.2.17.zip (9.0 kB view details)

Uploaded Source

File details

Details for the file lorm-0.2.17.zip.

File metadata

  • Download URL: lorm-0.2.17.zip
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for lorm-0.2.17.zip
Algorithm Hash digest
SHA256 2b6f8bf26c70d4bd5ca723e92bf45d326f8ce27b6914a0c5012ae45734f6dc00
MD5 7fb3706ee266b4e27db9f280a8b496f2
BLAKE2b-256 71b79c6b81d4088fd41eab01eac971f56f6b7f393b4abc2a4cedcd3187ed20f1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page