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.1.tar.gz
(3.8 kB
view details)
Built Distribution
File details
Details for the file sql_manager-1.0.1.tar.gz
.
File metadata
- Download URL: sql_manager-1.0.1.tar.gz
- Upload date:
- Size: 3.8 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 | b4bece69b7242841623d846047ad0da23fb997b3f4292b59f9d272635d6dc4b1 |
|
MD5 | 8a416e4ea766ca6b8965e9e874869781 |
|
BLAKE2b-256 | a2df8eb001144a9402c31f61292d3316d9e027db70cb2aab7eb70e5045731d23 |
File details
Details for the file sql_manager-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: sql_manager-1.0.1-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 | e6a9b1515b1958b3ed6ee9d3cef79476ac74ee8a2e5493b4486b5577a91d39d0 |
|
MD5 | 31a1a084f7c65742a00d5eec4799adb8 |
|
BLAKE2b-256 | c6bddf189900d763890b88278d1dd94d89ec7ae233c3fdfd6c1e5a8363c4f58e |