Skip to main content

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.
  • Table Management: Create, drop, and truncate tables.
  • Row Counting: Count the number of rows in a table.
  • Fetch by ID: Retrieve a single row by its ID.

Installation

You can install ODETA using pip:

pip install odeta

Usage

Initialization

First, import the LocalBase class and create a database instance:

from odeta import LocalBase

db = LocalBase('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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

odeta-0.3.1.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

odeta-0.3.1-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file odeta-0.3.1.tar.gz.

File metadata

  • Download URL: odeta-0.3.1.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for odeta-0.3.1.tar.gz
Algorithm Hash digest
SHA256 2cd6aaf1db1c2b14a970313b5412f617f671c98142116c8fbd99dfa2e143a974
MD5 51173372323007e7313e333f3a62a9f3
BLAKE2b-256 1342045b282942a8f1a048914f30e2d902ffe30b8ebf8150cd1f30ec28d2d8da

See more details on using hashes here.

File details

Details for the file odeta-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: odeta-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for odeta-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 62170a50147d763e3b5c27ce038018627d26c145d6ff1af12d0ab37db86492a3
MD5 86ab320945706666434f8d5b64c6e49d
BLAKE2b-256 2baa21ce89388b8d9d2a35dd7b5277efdcc96b63441109d3ff46e5cb6302dcff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page