Skip to content

gabrielfalcao/chemist

Repository files navigation

Chemist

A simple, flexible and testable active-record powered by SQLAlchemy.

Documentation Status

image

Install

pip install chemist

Documentation

chemist.readthedocs.io

Basic Usage

from chemist import (
    Model, db, DefaultTable
    set_default_uri,
)

engine = set_default_uri('sqlite:///example.db')

class BlogPost(Model):
     table = DefaultTable('blog_post'
         db.Column('id', db.Integer, primary_key=True),
         db.Column('title', db.Unicode(200), nullable=False),
         db.Column('content', db.UnicodeText, nullable=False),
     )

post1 = BlogPost.create(title='Hello World', content='\n'.join([
    'Introduction...',
    'Supporting Theory 1...',
    'Supporting Theory 2...',
    'Supporting Theory 3...',
    'Conclusion',
]))


for post in BlogPost.all():
    print(post.title, post.id)

Examples

  1. flask app