https://github.com/austinhyde/rowhouse
A SQLAlchemy wrapper that stays out of your way
https://github.com/austinhyde/rowhouse
database python sql
Last synced: 2 days ago
JSON representation
A SQLAlchemy wrapper that stays out of your way
- Host: GitHub
- URL: https://github.com/austinhyde/rowhouse
- Owner: austinhyde
- License: mit
- Created: 2016-11-21T01:03:05.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-13T20:29:19.000Z (almost 9 years ago)
- Last Synced: 2026-04-28T04:37:54.075Z (2 days ago)
- Topics: database, python, sql
- Language: Python
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Rowhouse
##############################################
|version| |build|
*For when you just want to write SQL*
Rowhouse is a SQLAlchemy wrapper that attempts to strike a happy medium between using raw database bindings like
psycopg2 and using the full SQLAlchemy API.
Use it when:
* You don't want to mess with connections, cursors, sessions, etc
* You don't need or want an ORM or repository
* You don't want to look up SQLAlchemy's expression language every time you need a non-trivial query
* You just want to write some SQL, and work with plain old dicts and lists
* You want some convenient helper functions for common operations
Install
=======
.. code-block:: bash
pip install rowhouse
Basic Usage
===========
.. code-block:: python
from rowhouse import Connection
db = Connnection('postgresql://localhost/mydatabase')
# Run some SQL
row = db.fetchone('SELECT * FROM users WHERE username = %s', ('mreynolds',))
print('Name = ' + row['fullname'])
for row in db.fetchiter('SELECT * FROM users'):
print('User: ' + row['fullname'])
db.begin()
db.execute('CREATE TABLE groups (...)')
db.execute('INSERT INTO groups VALUES (%s, %s)', ('firefly', 'mreynolds'))
db.commit()
# Some convenient helpers
with db.transaction():
row = db.findone('users', username='mreynolds')
db.update('users', {
'role': 'captain'
}, id=row['id'])
newrow = db.insert('users', {
'fullname': 'Zoe Washburne',
'username': 'zwashburne',
'role': 'first_mate'
})
To Do
=====
- [x] Implement find* methods
- [x] Implement insert/update/delete/upsert methods
- [x] Add tests and CI
- [x] Add packaging and publish to pypi
- [ ] More configurability - constructor, setters, etc
- [ ] **Simple** model support - little more than classes with a Connection baked in and some convenience methods
.. |version| image:: https://img.shields.io/badge/version-1.0.3-blue.svg
.. |build| image:: https://img.shields.io/travis/austinhyde/rowhouse/master.svg
:target: https://travis-ci.org/austinhyde/rowhouse
:alt: Build status of master branch