S42-Core SQLite Class
- SQLite Class Documentation
SQLite Class Documentation
The SQLite
class is part of the s42-core
package and provides a comprehensive and efficient interface for interacting with SQLite databases. It supports common operations like creating, updating, querying, and deleting data, as well as advanced features such as schema management, indexing, and MongoDB-style query translation.
Key Features
- Flexibility: Support for both in-memory and file-based SQLite databases.
- CRUD Operations: Simplified methods for
INSERT
,SELECT
,UPDATE
, andDELETE
operations. - Schema Management: Create, drop, and alter tables dynamically.
- Pagination Support: Built-in
LIMIT
andOFFSET
options for efficient query handling. - Indexing: Create indexes to optimize query performance.
- Metadata Access: Retrieve a list of all tables and their schemas.
- MongoDB-like Queries: Translate MongoDB-style queries to SQL for seamless integration.
- Error Handling: Built-in validations and descriptive error messages to ensure reliability.
Installation
To use the SQLite
class, install the s42-core
package:
Usage Examples
Initialization
Creating and Managing Tables
Create a Table
Drop a Table
Add Columns to an Existing Table
CRUD Operations
Insert Data
Select Data
Update Data
Delete Data
Indexing
Create an Index
Metadata Access
Get All Tables
Get Table Schema
Advantages of Using the SQLite Class
- Ease of Use: Simplifies complex SQLite operations into a clean and intuitive API.
- Seamless Integration: MongoDB-style query translation enables smooth integration with applications that use MongoDB-like query syntax.
- Performance Optimization: Features like indexing and pagination ensure efficient data handling.
- Dynamic Schema Management: Easily modify tables without manual SQL.
- Error Resilience: Validations and detailed error messages help prevent and debug issues.
- Extensibility: Built with flexibility to support additional features like transactions and batch operations.
- Real-Time Query Building: Dynamically construct queries with filtering, sorting, and limiting.
Error Handling
The class includes robust error handling:
- Ensures valid table and column names.
- Throws descriptive errors when operations fail.
- Logs errors to help debug issues effectively.
License
This project is licensed under the MIT License. See the LICENSE file for details.