A framework-independent wrapper for SQLAlchemy that makes it really easy to use.
Project description
SQLA-wrapper
A friendly wrapper for SQLAlchemy.
Installation
Install the package using Pypi:
pip install sqla-wrapper
There is another package on Pypi called SQLAlchemy-Wrapper
which is
deprecated (do not use it!). Use sqla-wrapper
instead.
Basic usage
from sqla_wrapper import SQLAlchemy
db = SQLAlchemy('sqlite:///:memory:')
class ToDo(db.Model):
id = db.Column(db.Integer, primary_key=True)
...
db.create_all()
db.add(Todo(...))
db.commit()
# Sorry, we don't support the `Model.query` syntax yet
todos = db.query(ToDo).all()
Read the complete documentation here: https://jpscaletti.com/sqla-wrapper
Since 2.0, only Python 3.6 or later are supported. Please use the 1.9.1 version if your project runs on a previous Python version.
Our test suite runs continuously on Travis CI with every update.
SQLAlchemy
The things you need to know compared to plain SQLAlchemy are:
- The
SQLAlchemy
gives you access to the following things:- All the functions and classes from
sqlalchemy
andsqlalchemy.orm
- All the functions from a preconfigured scoped session (called
_session
). - The
~SQLAlchemy.metadata
and~SQLAlchemy.engine
- The methods
SQLAlchemy.create_all
andSQLAlchemy.drop_all
to create and drop tables according to the models. - a
Model
baseclass that is a configured declarative base.
- All the functions and classes from
- All the functions from the session are available directly in the
class, so you can do
db.add
,db.commit
,db.remove
, etc. - The
Model
declarative base class behaves like a regular Python class but has aquery
attribute attached that can be used to query the model. - The
Model
class also auto generates_tablename__
attributes, if you don't define one, based on the underscored and pluralized name of your classes. - You have to commit the session and configure your app to remove it at the end of the request.
Copyright 2013 by Juan-Pablo Scaletti.
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
Hashes for sqla_wrapper-2.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 402e74e4c472a80c20b3c11600cfe80fe2b93465df3fc90dff8fa6cbbac6f43d |
|
MD5 | 9f2f88e0832bed4ff3a46d660a9f532a |
|
BLAKE2b-256 | 350896e0f41efa7dcbb78539dbd47c1a42d63ff56f47a65bf67be7be9b9f4b97 |