sqlgen Documentation
Welcome to the sqlgen documentation. This guide provides detailed information about sqlgen’s features and APIs.

Core Concepts
How to install sqlgen.
How to define tables using C++ structs.
How to represent columns in queries.
How to use column and table alias literals in queries.
How to "inherit" fields from other structs.
How to define primary keys in sqlgen.
How sqlgen handles errors and results.
How to transpile C++ operations to dialect-specific SQL.
Database I/O
Database Operations
How to create tables and views from SELECT queries.
How to create an index on a table.
How to create a new table.
How to delete data from a table.
How to drop a table.
How to execute raw SQL statements.
How to generate GROUP BY queries and aggregate data.
How to join different tables.
How to insert data within transactions.
How to read data from a database using more complex queries.
How to combine results from multiple SELECT statements.
How to update data in a table.
Other Operations
How to improve performance with caching.
How to use mathematical functions in queries (e.g., abs, ceil, floor, exp, trigonometric functions, round).
How to manipulate and transform strings in queries (e.g., length, lower, upper, trim, replace, concat).
How to convert between types safely in queries (e.g., cast int to double).
How to handle nullable values and propagate nullability correctly (e.g., with coalesce and nullability rules).
How to work with timestamps, dates, and times (e.g., extract parts, perform arithmetic, convert formats).
How to work with enums in sqlgen.
Data Types and Validation
How to define custom SQL types not natively supported by sqlgen.
How to establish referential integrity between tables.
How to store and work with JSON fields.
How to add regex pattern validation to avoid SQL injection.
How timestamps work in sqlgen.
How to enforce uniqueness constraints on table columns.
How varchars work in sqlgen.
Other concepts
How to manage database connections efficiently.
How to use transactions for atomic operations.
How to create and manage database views.
Supported Databases
How to interact with DuckDB.
How to interact with MariaDB and MySQL.
How to interact with PostgreSQL and compatible databases (Redshift, Aurora, Greenplum, CockroachDB, …).
How to interact with SQLite3.
For installation instructions, quick start guide, and usage examples, please refer to the main README.