A simple database manager with sqlalchemy
Project description
A simple database manager with sqlalchemy
Installation
python3 -m pip install sql_manager
Basic Usage
from sqlalchemy import Column, Integer
from sql_manager import DynamicModel, Manager
# create model
columns = {
'uid': Column(Interger, primary_key=True),
'name': Column(String(10), comment='the username')}
Base, Data = DynamicModel('TEST', columns, 'test')
# insert data
with Manager(Base, dbfile='test.db') as m:
data = Data(uid=1, name='zoro')
m.insert(Data, 'uid', data)
# query, delete
with Manager(Base, dbfile='test.db') as m:
res = m.query(Data, 'uid', 1)
print(res.all())
m.delete(Data, 'uid', 1)
# other origin methods
with Manager(Base, dbfile='test.db') as m:
query = m.session.query(Data)
query.filter(Data.name.like('%zo%')).limit(1)
Document
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sql_manager-1.0.0.tar.gz
(3.7 kB
view details)
Built Distribution
File details
Details for the file sql_manager-1.0.0.tar.gz
.
File metadata
- Download URL: sql_manager-1.0.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a0666313df2c9615f173570bf016fca5b70a958196b4663ccc4d66b47cbc1dc |
|
MD5 | 56e8a79baba3f07cda27bcaa444b74ea |
|
BLAKE2b-256 | 6a258fce9f69a903b5eca8ff70c23e2f175fa26fef09cbeb5676f518e26cd145 |
File details
Details for the file sql_manager-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: sql_manager-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1ce6ec77af8e8cc7d106d0c27cc26a2a17e1cd9c49ca1832869af8e582a3505 |
|
MD5 | 1685fb8891101ede59badaaf9801ebd3 |
|
BLAKE2b-256 | d78dec021e1d0c45ba20a4280339137bafc4d6e5ef68848c854f08f55986f42a |