The easy ORM for Python

pip install jardin

Configure

# jardin_conf.py

import logging

DATABASES = {
    'mydb1_master': 'https://...',
    'mydb1_replica': 'https://...',
}

LOG_LEVEL = logging.DEBUG

WATERMARK = 'MyCoolApp'

Configure access to as many databases as you need.

Declare

# db_models.py

import jardin

class Db1AbstractModel(jardin.Model):
    db_names = {
        'master': 'mydb1_master',
        'replica': 'mydb1_replica'
        }

class User(Db1AbstractModel): pass

Declare your models, one per database table. Singular names for plural tables, ActiveRecord-style.

Profit

>>> from db_models import User
>>> user = User.insert(values={'name': 'jardin'})
User(id=123, name='jardin')
>>> User.select(where={'active': False})
        name   active
0     jardin    False
1    sqlalch    False
>>> user.active = True
>>> user.save()
>>> User.select(where={'active': True})
        name   active
0     jardin    True

Use jardin to interact with your database in a clean and esthetic way.

Jardin is fully featured

  • Works with python 3.5+
  • PostgreSQL, MySQL, SQLite, and Snowflake supported
  • Support for multiple databases with master/replica split
  • Transparent connection drop recovery
  • Single-statement dataframe insertion
  • À la ActiveRecord query scopes
  • created_at, updated_at and soft-deletes out-of-the-box support

jardin is an open-source package supported by Instacart – We're hiring.
MIT license, © 2018 Instacart.