RDBMS
Relational Database Management System
Installing
Install and update using pip3:
$ pip3 install rdbms
Python 3 and newer.
Simple Usage
from rdbms import RDBMS
class User(RDBMS):
path = './test_sqlite.db' # default in-memory usage
def setup(self):
"""
CREATE TABLE IF NOT EXISTS user
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
password CHAR(200)
);
"""
def create_user(self, name, password):
"""
INSERT INTO user (name, password)
VALUES ('{name}', '{password}')
"""
def get_user(self, name):
"""
SELECT * FROM user
WHERE name = '{name}'
"""
def execute_script_example(script=True):
"""
Run script
"""
if __name__ == '__main__':
user = User()
user.create_user(name='username', password='1234')
users = user.get_user(name='username')
assert users[0].name == 'username'
assert users[0].name == users[0]['name']
Parameters Example
from rdbms import RDBMS
class Test(RDBMS):
def setup(self): # not required | script parameter defaults to True for setup function
"""
Some SQL script
"""
def script_execute(self, script=True): # run script | script default False
"""
Some SQL script
"""
def iterable_object(self, iterable=True): # return generator | iterable default False
"""
Some SQL query
"""
def fixed_size(self, size=1): # fixed size data return | size default None
"""
Some SQL query
"""
Function Example
from rdbms import RDBMS
def titlecase(text):
return text.title()
class Test(RDBMS):
...
def get_test_function_data(self, data):
"""
SELECT titlecase(name) FROM test WHERE name='{data}'
"""
if __name__ == '__main__':
test = Test()
test.add_function(titlecase)
result = self.test.get_test_function_data(data='test name')
assert result[0].name == 'Test Name'
Aggregate Example
from rdbms import RDBMS
class mysum:
def __init__(self):
self.count = 0
def step(self, value):
self.count += value
def finalize(self):
return self.count
class Test(RDBMS):
...
def get_test_aggregate_data(self):
"""
SELECT mysum(age) FROM test
"""
if __name__ == '__main__':
test = Test()
test.add_aggregate(mysum)
result = test.get_test_aggregate_data()
assert result[0]['mysum(age)'] == 100
Collaction Example
from rdbms import RDBMS
def collate_reverse(string1, string2):
if string1 == string2:
return 0
elif string1 < string2:
return 1
else:
return -1
class Test(RDBMS):
...
def get_test_collation_data(self):
"""
SELECT name FROM test ORDER BY name COLLATE collate_reverse
"""
if __name__ == '__main__':
test = Test()
test.add_collaction(collate_reverse)
result = test.get_test_collation_data()
assert result[0]['name'] == 'b'
assert result[1]['name'] == 'a'
Text Factory Example
from rdbms import RDBMS
from rdbms.text_factories import text_factory_bytes
class Test(RDBMS):
...
if __name__ == '__main__':
test = Test()
test.set_text_factory(text_factory_bytes)
data = test.get_data()
assert result[0].attribute, bytes
Row Factory Example
from rdbms import RDBMS
from rdbms.text_factories import dict_factory
class Test(RDBMS):
...
if __name__ == '__main__':
test = Test()
test.set_row_factory(dict_factory)
data = test.get_data()
assert 'attribute' in result[0]
Support
Python 3.x
Supports all operating systems
Links
License: MIT License
Metadata
Release files for rdbms 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rdbms-1.0.2.tar.gz | 4.5 kB | Without provenance | Details for rdbms-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rdbms-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for rdbms-1.0.2-py3-none-any.whl |
Total release size: 9.5 kB
Release files / rdbms-1.0.2.tar.gz
| Download URL | rdbms-1.0.2.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a45ebdb4c2696b1763cb3e9726d11bff688c352002036ab2d68ab363b0973edb
|
|
BLAKE2b-256 checksum How to use checksums |
01e184470fb8aff19765a10da5f19240ab7e8988ac0cbaf183c406bc1b2f0a43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
|
Release files / rdbms-1.0.2-py3-none-any.whl
| Download URL | rdbms-1.0.2-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
501b2fb77bef159c776bd82c5c5f1c540c600a31e84ee9b0fee1c405d23692bf
|
|
BLAKE2b-256 checksum How to use checksums |
8519dd4db1c85af96eb49b4b46422e7ecc0ee68a43581a1427b84a0dbd53fd8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
|
Security for rdbms 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.