Wrapper to make using SqlAlchemy easier, thread safe, helper methods etc.
Project description
SqlAlchemy-Tools
SqlAlchemy_Tools is a tool that provides similar functionality to Flask_SqlAlchemy without being dependant on Flask.
Installation
Install SqlAlchemy-Tools with pip:
pip install sqlalchemy-tools
Features
- Thread safe by using
scoped_session
- Integration with Pandas to allow quick dataframe insertion and retriving queries as dataframes
- GetOrCreate functionality
- Checking if an object is valid
- Other general helper methods for creating/getting information
Example
from sqlalchemy import (Column, String, Integer, ForeignKey)
from sqlalchemy_tools import Database
db = Database('sqlite:///tmp.db')
class User(db.Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String)
fullname = Column(String)
nickname = Column(String)
db.create_all_metadata() # only required if not using alembic or using a database in memory
# db.register_model(User) # optional to allow for single imports, allows models to be accessed as `db.User`
u1 = User(name='Dave', fullname='Dave Smith', nickname='Davo')
u2 = User(name='Dave', fullname='Dave Owen', nickname='Dav Machine')
db.save([u1, u2])
u3 = db.get_or_create(User, {'name': 'Simon'})
User.query.all()
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
Built Distribution
Close
Hashes for SqlAlchemy_Tools-0.0.1b2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03d288e3b29fb486934e323846935a01a51d89f828bd37f7d88ea2776dc4949b |
|
MD5 | 8ce999f17f23cd3aa432ed9ef9e2b993 |
|
BLAKE2b-256 | 607d2714431c808c1a8ed04f62a032072a110a94d1a1f561a531e64a138462aa |