|
Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
|
Introductory C++20 examples demonstrating the core features of database_system. Each example focuses on a single feature area and is designed to be read top-to-bottom.
| Example | File | Database Required | Description |
|---|---|---|---|
| Basic Connection | basic_connection.cpp | Yes | Connect to PostgreSQL, create a table, insert and query data, disconnect. |
| Query Builder | query_builder_usage.cpp | No | Build SELECT, INSERT, UPDATE, DELETE queries using the fluent API. Demonstrates joins, grouping, conditions, and dialect switching. |
| Transaction Management | transaction_management.cpp | Yes | Begin, commit, and rollback transactions. Includes a RAII transaction guard pattern. |
| Error Handling | error_handling.cpp | Partial | Use Result<T> and VoidResult to handle connection failures, invalid SQL, constraint violations, and chained operations. |
| ORM Entity | orm_entity_demo.cpp | No | Define entity classes with field metadata and constraints. Generate CREATE TABLE SQL and inspect metadata programmatically. |
| Connection Pool | connection_pool_demo.cpp | Yes | Multi-threaded database usage with independent database_manager instances per thread. |
Examples are built when the BUILD_DATABASE_EXAMPLES CMake option is enabled (default: OFF):
The example binaries are placed in build/bin/:
Two examples (query_builder_usage and orm_entity_demo) do not require a running database server. They demonstrate API usage by generating SQL strings and inspecting metadata in-memory.
For examples that require a database:
The samples/ directory contains more comprehensive integration-level programs. These examples/ are intentionally simpler and focused on introducing individual API features to new users.