A simple NoSQL-like interface for SQLite
Project description
ODETA
ODETA is a lightweight ORM-like library for SQLite that allows you to perform NoSQL-like operations. It provides a simple and intuitive interface for interacting with SQLite databases, making it easy to store and retrieve JSON data.
Features
- CRUD Operations: Easily perform create, read, update, and delete operations.
- Querying: Support for simple and complex queries.
- ULID Generation: Automatically generate ULIDs for unique record identifiers.
Installation
You can install ODETA using pip:
pip install odeta
Usage
Initialization
First, import the database function and create a database instance:
from odeta import database
db = database('my_database.db')
Creating and Inserting Data
Create a table and insert data:
table = db('my_table')
data = {
'name': 'John Doe',
'age': 30,
'email': 'john.doe@example.com'
}
response = table.put(data)
print(response) # {'id': 'system_generated_unqiue_id', 'msg': 'success'}
Querying Data
Fetch all records or filter records based on a query:
# Fetch all records
all_records = table.fetchall() # You can put query too in this fetchall({...}), it will gather all rows with OR condition.
print(all_records)
# Fetch records with a specific query AND condition.
filtered_records = table.fetch({'name?contains': 'John'})
print(filtered_records)
Updating Data
Update a record by its ID:
update_data = {
'name': 'Jane Doe',
'age': 25,
'email': 'jane.doe@example.com'
}
table.update(update_data, 'record_id')
Deleting Data
Delete a record by its ID:
table.delete('record_id')
Additional Operations
Truncate Table
Remove all rows from the table:
table.truncate()
Drop Table
Completely remove the table from the database:
table.drop()
Count Rows
Count the number of rows in the table:
row_count = table.count()
print(row_count)
Find by ID
Retrieve a single row by its ID:
record = table.get('record_id')
print(record)
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Contact
For any questions or feedback, please contact tech.manujpr@gmail.com.
Thank you for using ODETA!
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file odeta-0.1.43-py3-none-any.whl.
File metadata
- Download URL: odeta-0.1.43-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef0d2946b2b45b15660347700764c917a6c793173b8b11be1ef1690a0f129c61
|
|
| MD5 |
45039175e06c246a8e4b897ed04a0064
|
|
| BLAKE2b-256 |
5c25c4c3703abde50fa782a959158e7f2ffd782852aaab28762a32a390c10174
|