Plastic ORM
An ORM that molds itself to the data
Currently in beta validation. SQLite is the initial test.
See the dev/ directory for example usage.
Quickstart
Here's a quick way to get some data out of a SQLite database file:
from plastic.connectors.sqlite import PlasticSqlite
PlasticSqlite._dbInfo = './dev/sqlite-test.db'
class Task(PlasticSqlite): pass
print(Task.find(Task.id[3:]))
# [task(id=4,active=0,title='Uninteresting',description='Not much to say here.'),
# task(id=5,active=1,title='Very important',description=None)]
To change a record you can set it this way:
task = Task(id=4)
print(task)
# task(id=4,active=0,title='Uninteresting',description='Not much to say here.')
task.title = "A bit more interesting"
task._commit()
print(Task(id=4))
# task(id=4,active=0,title='A bit more interesting',description='Not much to say here.')
Note: To avoid the need to call
_commit(), set_autocommit=True. This can be done at the object or class level. Also note that for SQLite a commit means the database file is updated!
Any column of the table can be referenced as an attribute, and they can also be used as a filter. For example, to find the tasks that are still active:
print({task.title: task.description
for task
in Task.find(Task.active[0])})
# {'Skipped': None, 'A bit more interesting': 'Not much to say here.'}
Add an entry by instantiating without a bound key:
newTask = Task()
newTask.title = "A new task to do"
newTask.active = True
newTask._commit()
print(Task.find(Task.id[5:])) # get tasks after the last added
# [task(id=6,active=1,title='A new task to do',description=None)]
Deletion is not yet supported. It wouldn't be hard, but there needs to be some sort of interlocking.
Metadata
Release files for plastic 0.2.0
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 |
|---|---|---|---|---|
| plastic-0.2.0.tar.gz | 16.4 kB | Without provenance | Details for plastic-0.2.0.tar.gz |
Release files / plastic-0.2.0.tar.gz
| Download URL | plastic-0.2.0.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55f88753229f8c2fd13829e5e5243005abfbbffcb7a58d223d910d1371e7fead
|
|
BLAKE2b-256 checksum How to use checksums |
02d18a012e6d09e881a230927a61b3aaca7c6c734a0100b25a2922e78111be66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.5.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Security for plastic 0.2.0
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.