A python library that allows you to work with sql easily
Project description
sqbooster
A Python library that provides a flexible and easy-to-use interface for working with various databases, including SQLite, JSON, Pickle, Redis, MongoDB, and PostgreSQL.
Features
- Multiple Database Support: Work with SQLite, JSON files, Pickle files, Redis, MongoDB, and PostgreSQL
- Consistent API: Same interface across all database types
- Automatic Serialization: Built-in JSON serialization/deserialization for complex data types
- Lightweight: Minimal dependencies for core functionality
- Optional Integrations: Support for popular databases like Redis and MongoDB
- Type Safety: Python type hints for better IDE support
- Error Handling: Robust error handling and informative exceptions
Installation
pip install sqbooster
Quick Start
from sqbooster.databases import SQLiteDatabase, JSONFileDatabase, PickleFileDatabase
# SQLite Example
db_sqlite = SQLiteDatabase("test.db")
db_sqlite.write("key1", {"name": "test", "value": 123})
print("SQLite:", db_sqlite.read("key1"))
# JSON File Example
db_json = JSONFileDatabase("test.json")
db_json.write("key1", {"name": "test", "value": 123})
print("JSON File:", db_json.read("key1"))
# Pickle File Example
db_pickle = PickleFileDatabase("test.pkl")
db_pickle.write("key1", {"name": "test", "value": 123})
print("Pickle File:", db_pickle.read("key1"))
Advanced Usage
Redis Integration
from sqbooster.databases import RedisDatabase
try:
db_redis = RedisDatabase()
db_redis.write("key1", {"name": "test", "value": 123})
print("Redis:", db_redis.read("key1"))
except ImportError:
print("Redis not available")
MongoDB Integration
from sqbooster.databases import MongoDatabase
try:
db_mongo = MongoDatabase()
db_mongo.write("key1", {"name": "test", "value": 123})
print("MongoDB:", db_mongo.read("key1"))
except ImportError:
print("MongoDB not available")
PostgreSQL Integration
from sqbooster.databases import PostgreSQLDatabase
try:
db_postgres = PostgreSQLDatabase()
db_postgres.write("key1", {"name": "test", "value": 123})
print("PostgreSQL:", db_postgres.read("key1"))
except ImportError:
print("PostgreSQL not available")
API Reference
All database classes implement the following core methods:
write(key, value): Store a value with the given keyread(key): Retrieve a value by keydelete(key): Remove a key-value pairexists(key): Check if a key existsclear(): Remove all key-value pairs
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Ali Safamanesh (darg.q.a.a@gmail.com)
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
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 sqbooster-1.0.0.tar.gz.
File metadata
- Download URL: sqbooster-1.0.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c92e8a39629ab386da8f633acba7b38070e6e9a70385c8f82edfc3553dd661d
|
|
| MD5 |
b57bc05139c48ad931d565172e2255aa
|
|
| BLAKE2b-256 |
84b6c4daa62cb6f7e4a927a2928225770dcdf11eb9327f5beedc94afc755fafb
|
File details
Details for the file sqbooster-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sqbooster-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5e108c2455b92fd9bf59fec6d0032874292d0574c9e29fe0862a6dea1891046
|
|
| MD5 |
502bca3322af5fdaac3432f374a545d7
|
|
| BLAKE2b-256 |
f4e6e2c3fa53599eca5ab35684ad53a1d8d7e82762e25633883e7fb068a736a6
|