mirror of
https://github.com/getml/sqlgen.git
synced 2025-12-31 06:30:18 -06:00
3.1 KiB
3.1 KiB
sqlgen Documentation
Welcome to the sqlgen documentation. This guide provides detailed information about sqlgen's features and APIs.
Core Concepts
- Defining Tables - How to define tables using C++ structs
- sqlgen::col - How to represent columns in queries
- sqlgen::literals - How to use column and table alias literals in queries
- sqlgen::Flatten - How to "inherit" fields from other structs
- sqlgen::PrimaryKey - How to define primary keys in sqlgen
- sqlgen::Result - How sqlgen handles errors and results
- sqlgen::to_sql - How to transpile C++ operations to dialect-specific SQL
Database I/O
- sqlgen::read - How to read data from a database
- sqlgen::write - How to write data to a database
Database Operations
- sqlgen::create_index - How to create an index on a table
- sqlgen::create_table - How to create a new table
- sqlgen::delete_from - How to delete data from a table
- sqlgen::drop - How to drop a table
- sqlgen::exec - How to execute raw SQL statements
- sqlgen::group_by and Aggregations - How generate GROUP BY queries and aggregate data
- sqlgen::inner_join, sqlgen::left_join, sqlgen::right_join, sqlgen::full_join - How to join different tables
- sqlgen::insert - How to insert data within transactions
- sqlgen::update - How to update data in a table
Other Operations
- Mathematical Operations - How to use mathematical functions in queries (e.g., abs, ceil, floor, exp, trigonometric functions, round).
- String Operations - How to manipulate and transform strings in queries (e.g., length, lower, upper, trim, replace, concat).
- Type Conversion Operations - How to convert between types safely in queries (e.g., cast int to double).
- Null Handling Operations - How to handle nullable values and propagate nullability correctly (e.g., with coalesce and nullability rules).
- Timestamp and Date/Time Functions - How to work with timestamps, dates, and times (e.g., extract parts, perform arithmetic, convert formats).
Data Types and Validation
- sqlgen::Pattern - How to add regex pattern validation to avoid SQL injection
- sqlgen::Timestamp - How timestamps work in sqlgen
- sqlgen::Varchar - How varchars work in sqlgen
Other concepts
- Connection Pool - How to manage database connections efficiently
- Transactions - How to use transactions for atomic operations
Supported Databases
- PostgreSQL - How to interact with PostgreSQL and compatible databases (Redshift, Aurora, Greenplum, CockroachDB, ...)
- SQLite - How to interact with SQLite3
For installation instructions, quick start guide, and usage examples, please refer to the main README.