Fork me on GitHub

PyORMish is a light-weight ORM-like utility for Python. Designed to work with existing schemas, PyORMish allows a programmer to quickly map schema to objects.

Basic Features

  • Works with MySQL (and MariaDB), SQLite, and Postgres.
  • Uses an existing schema.
  • Properly handles MySQLdb Unicode.
  • Automatic property mapping for getters and setters.
  • Seamlessly handles lists of objects.
  • Extremely small. The entire codebase is less than 5kB.

Basic Usage

from pyormish import Model

class User(Model):
    _TABLE_NAME = 'users'
    _PRIMARY_FIELD = 'id'
    _SELECT_FIELDS = ('id','username','fullname')
    _COMMIT_FIELDS = ('username','fullname')

# Tell Model to use an existing database
Model.db_config = dict(DB_TYPE='sqlite', DB_PATH='/path/to/mydb.sqlite')
# Load all users (WHERE 1)
users = User().get_many_by_where('1')
for user in users:
    # Print some data about the user
    print user.id, user.username, user.fullname