A library dedicated to easy and seamless handling of sqlite3 / db files
Project description
codedevdb Library
codedevdb is a powerful and easy-to-use Python library for managing SQLite databases. It provides a clean and intuitive interface for database operations, including connection management, query execution, table creation, data insertion, updating, deletion, and more. The library is designed to simplify database interactions while maintaining flexibility and efficiency.
🚀 Features
- ✅ Simple SQLite Database Management: Easily connect to and manage SQLite databases.
- ✅ Context Manager for Connection Handling: Automatically handles database connections and transactions.
- ✅ CRUD Operations: Create, Read, Update, and Delete data with simple methods.
- ✅ Table Management: Create, modify, and drop tables with ease.
- ✅ Bulk Insertion: Insert multiple records in a single operation.
- ✅ Index Creation: Improve query performance with custom indexes.
- ✅ Backup and Restore: Backup and restore your database with a single method.
- ✅ Schema Inspection: Retrieve table schema information.
- ✅ Error Handling: Robust error handling with rollback support.
📦 Installation
You can install codedevdb via pip:
pip install codedevdb
🔥 Usage
Importing the Library
import codedevdb
Connecting to a Database
# Connect to a SQLite database (or create it if it doesn't exist)
db = codedevdb('mydatabase.db')
Creating a Table
# Create a table with columns
db.create('users', id='INTEGER PRIMARY KEY', name='TEXT NOT NULL', age='INTEGER')
Inserting Data
# Insert a single record
db.insert('users', name='John', age=30)
# Insert multiple records
data = [
{'name': 'Alice', 'age': 25},
{'name': 'Bob', 'age': 28}
]
db.insert_bulk('users', data)
Fetching Data
# Fetch all records from the table
result = db.select('users')
print(result)
# Fetch specific columns with a condition
result = db.select('users', where="age > 25", columns=['name', 'age'])
print(result)
Updating Data
# Update records
db.update('users', where="name = 'John'", age=31)
Deleting Data
# Delete records
db.delete('users', where="name = 'John'")
Counting Records
# Count records
count = db.count('users', where="age > 25")
print(f"Number of users above 25: {count}")
Checking if Records Exist
# Check if a record exists
exists = db.exists('users', where="name = 'Alice'")
print(f"Does Alice exist? {exists}")
Dropping a Table
# Drop a table
db.drop_table('users')
Truncating a Table
# Truncate a table (delete all records)
db.truncate('users')
Inspecting Table Schema
# Get table schema
schema = db.schema('users')
print(schema)
Creating an Index
# Create an index on a column
db.create_index('users', 'idx_name', ['name'])
Backup and Restore
# Backup the database
db.backup('backup.db')
# Restore the database
db.restore('backup.db')
🌍 Compatibility
- Python: 3.8+
- Databases: SQLite3
🎯 Contribution
We welcome contributions! If you'd like to contribute to CodeDevDB, please open an issue or submit a pull request on GitHub.
📄 License
CodeDevDB is released under the MIT License.
📞 Contact
For any questions or support, feel free to reach out:
- Telegram Account: @midoghanam
- Telegram Channel: @mido_ghanam
Best Regards ♡
Thank you for using CodeDevDB! We hope it simplifies your database management tasks and makes your development process smoother. If you have any feedback or suggestions, please don't hesitate to reach out. Happy coding! 🚀
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 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 codedevdb-0.1.tar.gz.
File metadata
- Download URL: codedevdb-0.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8ba61e31688289a52e1889216063fc5aee5cf6b03b492766a82b414dce2a228
|
|
| MD5 |
ae374504005b9dcd6ae13f49b5dc7ed4
|
|
| BLAKE2b-256 |
277e02d95fd529ccb017183591c17a33263746ed5057b6f26b2074464cc1ca9e
|
File details
Details for the file codedevdb-0.1-py3-none-any.whl.
File metadata
- Download URL: codedevdb-0.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9efd82df46ad933203fe4c31dfd5d94410caae2c2285cba2807803f5ea76261
|
|
| MD5 |
aa9220dfdd889ca0fbc485aaba26bc21
|
|
| BLAKE2b-256 |
2a537236a57577c27c2e8d363930b9fa6c6955094c32be8bac2790937472065e
|