Metadata-Version: 2.1
Name: sqla-wrapper
Version: 2.0.2
Summary: A framework-independent wrapper for SQLAlchemy that makes it really easy to use.
Home-page: https://jpscaletti.com/sqla-wrapper
Author: Juan-Pablo Scaletti
Author-email: juanpablo@jpscaletti.com
License: MIT
Project-URL: Documentation, http://sqlawrapper.lucuma.co
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.6,<4.0
Description-Content-Type: text/markdown
Requires-Dist: inflection
Requires-Dist: sqlalchemy (~=1.0)
Provides-Extra: development
Requires-Dist: pytest-cov ; extra == 'development'
Requires-Dist: tox ; extra == 'development'
Requires-Dist: sphinx ; extra == 'development'
Provides-Extra: testing
Requires-Dist: pytest ; extra == 'testing'
Requires-Dist: mock ; extra == 'testing'

# SQLA-wrapper [![Build Status](https://travis-ci.org/jpscaletti/sqla-wrapper.png)](https://travis-ci.org/jpscaletti/sqla-wrapper)

A friendly wrapper for SQLAlchemy.


## Installation

Install the package using Pypi:

```bash
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

```python
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](https://travis-ci.org/jpscaletti/sqla-wrapper) with every update.


## SQLAlchemy

The things you need to know compared to plain SQLAlchemy are:

1.  The `SQLAlchemy` gives you access to the following things:
      - All the functions and classes from `sqlalchemy` and
        `sqlalchemy.orm`
      - All the functions from a preconfigured scoped session (called
        `_session`).
      - The `~SQLAlchemy.metadata` and `~SQLAlchemy.engine`
      - The methods `SQLAlchemy.create_all` and `SQLAlchemy.drop_all` to
        create and drop tables according to the models.
      - a `Model` baseclass that is a configured declarative base.
2.  All the functions from the session are available directly in the
    class, so you can do `db.add`, `db.commit`, `db.remove`, etc.
3.  The `Model` declarative base class behaves like a regular Python
    class but has a `query` attribute attached that can be used to query
    the model.
4.  The `Model` class also auto generates `_tablename__` attributes, if
    you don't define one, based on the underscored and **pluralized**
    name of your classes.
5.  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](http://jpscaletti.com).



