Make changes to sql tables using SqlAlchmey sessions
Project description
Sessionize: intutive Python SQL table manipulation toolkit
What is it?
Sessionize is a Python package that has an intuitive API that utilizes SqlAlchemy to connect to and manipulate records in SQL tables.
Main Features
Here are just a few of the things that Sessionize does well:
- Quickly and easily start a SQL session to insert, delete, and update records in SQL tables.
- Roll back any changes durring SQL session inside a context manager.
- Additional SQL migration functions for changing or adding primary keys, adding or dropping columns, renaming column and more.
Where to get it
The source code is currently hosted on GitHub at: https://github.com/eddiethedean/sessionize
# PyPI
pip install sessionize
Dependencies
- sqlalchemy - Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL
- alembic - a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python
Example
import sqlalchemy as sa
from sessionize import SessionTable
# Create SqlAlchemy engine to connect to database.
engine = sa.create_engine('sqlite:///foo.db')
# Create SessionTable to start session of table changes.
st = SessionTable('people', engine)
# Make changes to SessionTable:
# Add 1 to each value in the age column.
st['age'] + 1
# Update the first record with new values.
st[0] = {'id': 1, 'name': 'Olive', 'age': 18}
# Delete the last record.
del st[-1]
# Commit SessionTable to push changes to SQL table.
st.commit()
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
sessionize-0.0.17.tar.gz
(19.2 kB
view hashes)
Built Distribution
Close
Hashes for sessionize-0.0.17-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e31ec2629d6ff818d2b3f83879b499debf0bf9bffcc05c50046f9b18f6abbb42 |
|
MD5 | d94998c762978ccd13f47d451021fb72 |
|
BLAKE2b-256 | d848b87a07d0272451f9dbe3445ca1a3e9357541abeb661a5b45463e8089eb38 |