diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 0000000..c3c82dc --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,70 @@ +name: Deploy documentation to Github Pages + +on: + push: + branches: ["main"] + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +# Default to bash +defaults: + run: + shell: bash + +jobs: + # Build job + build: + runs-on: ubuntu-latest + env: + HUGO_VERSION: 0.156.0 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # fetch all history for .GitInfo and .Lastmod + submodules: recursive + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.26' + - name: Setup Pages + id: pages + uses: actions/configure-pages@v4 + - name: Setup Hugo + run: | + wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ + && sudo dpkg -i ${{ runner.temp }}/hugo.deb + - name: Build with Hugo + env: + # For maximum backward compatibility with Hugo modules + HUGO_ENVIRONMENT: production + HUGO_ENV: production + run: | + hugo --gc --minify --baseURL "${{ steps.pages.outputs.base_url }}/" + working-directory: docs + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./docs/public + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore index 27492ce..0cc1ce3 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ # Fortran module files *.mod *.smod +!docs/**/*.mod # Compiled Static libraries *.lai @@ -36,3 +37,6 @@ build/ vcpkg_installed/ CMakeUserPresets.json +docs/public/ +*.lock + diff --git a/README.md b/README.md index 16a019a..ef937cc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ![C++](https://img.shields.io/badge/c++-%2300599C.svg?style=for-the-badge&logo=c%2B%2B&logoColor=white) sqlgen +# ![C++](https://img.shields.io/badge/c++-%2300599C.svg?style=for-the-badge&logo=c%2B%2B&logoColor=white) sqlgen [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/getml/reflect-cpp/graphs/commit-activity) @@ -10,6 +10,8 @@ **πŸ“– Documentation**: [Click here](docs/README.md) +![image](docs/content/sqlgen.png) + **sqlgen** is a modern, type-safe ORM and SQL query generator for C++20, inspired by Python's [SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy)/[SQLModel](https://github.com/fastapi/sqlmodel) and Rust's [Diesel](https://github.com/diesel-rs/diesel). It provides a fluent, composable interface for database operations with compile-time type checking and SQL injection protection. sqlgen is based on and tightly integrated with [reflect-cpp](https://github.com/getml/reflect-cpp), a C++-20 library for fast serialization, deserialization and validation using reflection, similar to pydantic in Python, serde in Rust, encoding in Go or aeson in Haskell. @@ -24,9 +26,9 @@ Together, reflect-cpp and sqlgen enable reliable and efficient ETL pipelines. - πŸš€ **High Performance**: Efficient batch operations and prepared statements - πŸ“¦ **Modern C++**: Leverages C++20 features for a clean, expressive API - πŸ”Œ **Multiple Backends**: Support for PostgreSQL and SQLite -- πŸ” **Reflection Integration**: Seamless integration with [reflect-cpp](https://github.com/getml/reflect-cpp) +- πŸ” **Reflection Integration**: Seamless integration with [reflect-cpp](https://github.com/getml/reflect-cpp) -## Supported databases +## Supported databases The following table lists the databases currently supported by sqlgen and the underlying libraries used: @@ -41,7 +43,7 @@ The following table lists the databases currently supported by sqlgen and the un ### Install using vcpkg or Conan -You can install the latest release of sqlgen +You can install the latest release of sqlgen using either [vcpkg](https://vcpkg.io/en/package/sqlgen) or [Conan](https://conan.io/center/recipes/sqlgen). ### Build using vcpkg @@ -68,11 +70,11 @@ cmake --build build -j 4 # gcc, clang cmake --build build --config Release -j 4 # MSVC ``` -This will build the static library. To build the shared library +This will build the static library. To build the shared library add `-DBUILD_SHARED_LIBS=ON -DVCPKG_TARGET_TRIPLET=...` to the first line. -Run `./vcpkg/vcpkg help triplets` to view all supported triplets. -Common triplets for shared libraries are `x64-linux-dynamic`, -`arm64-osx-dynamic` or `x64-osx-dynamic`. +Run `./vcpkg/vcpkg help triplets` to view all supported triplets. +Common triplets for shared libraries are `x64-linux-dynamic`, +`arm64-osx-dynamic` or `x64-osx-dynamic`. Add `-DSQLGEN_MYSQL=ON` to support MySQL/MariaDB. Add `-DSQLGEN_DUCKDB=ON` to support DuckDB. @@ -102,7 +104,7 @@ conan build . --build=missing -s compiler.cppstd=gnu20 ``` This will build the static library. To build the shared library, -add `-o */*:shared=True`. +add `-o */*:shared=True`. Add `-o sqlgen/*:with_mysql=True` to support MySQL/MariaDB. @@ -130,14 +132,14 @@ struct User { int main() { // Connect to SQLite database const auto conn = sqlgen::sqlite::connect("test.db"); - + // Create and insert a user const auto user = User{.name = "John", .age = 30}; sqlgen::write(conn, user); - + // Read all users const auto users = sqlgen::read>(conn).value(); - + for (const auto& u : users) { std::cout << u.name << " is " << u.age << " years old\n"; } @@ -218,7 +220,7 @@ CREATE TABLE IF NOT EXISTS "Person" ( "email" TEXT ); -INSERT INTO "Person" ("first_name", "last_name", "age", "email") +INSERT INTO "Person" ("first_name", "last_name", "age", "email") VALUES (?, ?, ?, ?); COMMIT; ``` @@ -285,7 +287,7 @@ const std::vector children = get_children(conn).value(); Generated SQL: ```sql -SELECT +SELECT "last_name", COUNT(*) as "num_children", MAX("age") as "max_age", @@ -322,15 +324,15 @@ const auto get_people = Generated SQL: ```sql -SELECT t1."last_name" AS "last_name", - t1."first_name" AS "first_name_parent", - t3."first_name" AS "first_name_child", - t1."age" - t3."age" AS "parent_age_at_birth" -FROM "Person" t1 -INNER JOIN "Relationship" t2 -ON t1."id" = t2."parent_id" +SELECT t1."last_name" AS "last_name", + t1."first_name" AS "first_name_parent", + t3."first_name" AS "first_name_child", + t1."age" - t3."age" AS "parent_age_at_birth" +FROM "Person" t1 +INNER JOIN "Relationship" t2 +ON t1."id" = t2."parent_id" INNER JOIN "Person" t3 -ON t3."id" = t2."child_id" +ON t3."id" = t2."child_id" ORDER BY t1."id", t3."id" ``` @@ -363,26 +365,26 @@ const auto get_people = ("age"_t1 - "age"_t2) | as<"parent_age_at_birth">) | inner_join<"t2">( get_children, // Use the subquery as the source - "id"_t1 == "id"_t2) | + "id"_t1 == "id"_t2) | order_by("id"_t1, "id"_t2) | to>; ``` Generated SQL: ```sql -SELECT t1."last_name" AS "last_name", - t1."first_name" AS "first_name_parent", - t2."first_name" AS "first_name_child", - t1."age" - t2."age" AS "parent_age_at_birth" -FROM "Person" t1 +SELECT t1."last_name" AS "last_name", + t1."first_name" AS "first_name_parent", + t2."first_name" AS "first_name_child", + t1."age" - t2."age" AS "parent_age_at_birth" +FROM "Person" t1 INNER JOIN ( - SELECT t1."parent_id" AS "id", - t2."first_name" AS "first_name", - t2."age" AS "age" - FROM "Relationship" t1 + SELECT t1."parent_id" AS "id", + t2."first_name" AS "first_name", + t2."age" AS "age" + FROM "Relationship" t1 INNER JOIN "Person" t2 ON t2."id" = t1."child_id" -) t2 -ON t1."id" = t2."id" +) t2 +ON t1."id" = t2."id" ORDER BY t1."id", t2."id" ``` @@ -412,27 +414,27 @@ const auto get_people = select_from<"t1">( "last_name"_t1 | as<"last_name">, "first_name"_t1 | as<"first_name_parent">, "first_name"_t2 | as<"first_name_child">, - ("age"_t1 - "age"_t2) | as<"parent_age_at_birth">) | - inner_join("id"_t1 == "id"_t2) | + ("age"_t1 - "age"_t2) | as<"parent_age_at_birth">) | + inner_join("id"_t1 == "id"_t2) | order_by("id"_t1, "id"_t2) | to>; ``` Generated SQL: ```sql -SELECT t1."last_name" AS "last_name", - t1."first_name" AS "first_name_parent", - t2."first_name" AS "first_name_child", - (t1."age") - (t2."age") AS "parent_age_at_birth" +SELECT t1."last_name" AS "last_name", + t1."first_name" AS "first_name_parent", + t2."first_name" AS "first_name_child", + (t1."age") - (t2."age") AS "parent_age_at_birth" FROM ( - SELECT t2."child_id" AS "id", - t1."first_name" AS "first_name", - t1."last_name" AS "last_name", - t1."age" AS "age" - FROM "Person" t1 + SELECT t2."child_id" AS "id", + t1."first_name" AS "first_name", + t1."last_name" AS "last_name", + t1."age" AS "age" + FROM "Person" t1 INNER JOIN "Relationship" t2 ON t1."id" = t2."parent_id" -) t1 -INNER JOIN "Person" t2 +) t1 +INNER JOIN "Person" t2 ON t1."id" = t2."id" ORDER BY t1."id", t2."id" ``` @@ -446,26 +448,26 @@ sqlgen provides comprehensive compile-time checks and runtime protection: const auto query = read> | where("color"_c == "blue"); -// Compile-time error: Cannot compare column "age" to a string +// Compile-time error: Cannot compare column "age" to a string const auto query = read> | where("age"_c == "Homer"); -// Compile-time error: "age" must be aggregated or included in GROUP BY +// Compile-time error: "age" must be aggregated or included in GROUP BY const auto query = select_from( "last_name"_c, - "age"_c + "age"_c ) | group_by("last_name"_c); -// Compile-time error: Cannot add string and int +// Compile-time error: Cannot add string and int const auto query = select_from( - "last_name"_c + "age"_c + "last_name"_c + "age"_c ); // Runtime protection against SQL injection -std::vector get_people(const auto& conn, +std::vector get_people(const auto& conn, const sqlgen::AlphaNumeric& first_name) { using namespace sqlgen; - return (read> | + return (read> | where("first_name"_c == first_name))(conn).value(); } diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 4536b23..0000000 --- a/docs/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# sqlgen Documentation - -Welcome to the sqlgen documentation. This guide provides detailed information about sqlgen's features and APIs. - -## Core Concepts - -- [Defining Tables](defining_tables.md) - How to define tables using C++ structs -- [sqlgen::col](col.md) - How to represent columns in queries -- [sqlgen::literals](literals.md) - How to use column and table alias literals in queries -- [sqlgen::Flatten](flatten.md) - How to "inherit" fields from other structs -- [sqlgen::PrimaryKey](primary_key.md) - How to define primary keys in sqlgen -- [sqlgen::Result](result.md) - How sqlgen handles errors and results -- [sqlgen::to_sql](to_sql.md) - How to transpile C++ operations to dialect-specific SQL - -## Database I/O - -- [sqlgen::read](reading.md) - How to read data from a database -- [sqlgen::write](writing.md) - How to write data to a database - -## Database Operations - -- [sqlgen::create_as](create_as.md) - How to create tables and views from SELECT queries -- [sqlgen::create_index](create_index.md) - How to create an index on a table -- [sqlgen::create_table](create_table.md) - How to create a new table -- [sqlgen::delete_from](delete_from.md) - How to delete data from a table -- [sqlgen::drop](drop.md) - How to drop a table -- [sqlgen::exec](exec.md) - How to execute raw SQL statements -- [sqlgen::group_by and Aggregations](group_by_and_aggregations.md) - How generate GROUP BY queries and aggregate data -- [sqlgen::inner_join, sqlgen::left_join, sqlgen::right_join, sqlgen::full_join](joins.md) - How to join different tables -- [sqlgen::insert, sqlgen::insert_or_replace](insert.md) - How to insert data within transactions -- [sqlgen::select_from](select_from.md) - How to read data from a database using more complex queries -- [sqlgen::unite and sqlgen::unite_all](unite.md) - How to combine results from multiple SELECT statements -- [sqlgen::update](update.md) - How to update data in a table - -## Other Operations - -- [Cache](cache.md) - How to improve performance with caching. -- [Mathematical Operations](mathematical_operations.md) - How to use mathematical functions in queries (e.g., abs, ceil, floor, exp, trigonometric functions, round). -- [String Operations](string_operations.md) - How to manipulate and transform strings in queries (e.g., length, lower, upper, trim, replace, concat). -- [Type Conversion Operations](type_conversion_operations.md) - How to convert between types safely in queries (e.g., cast int to double). -- [Null Handling Operations](null_handling_operations.md) - How to handle nullable values and propagate nullability correctly (e.g., with coalesce and nullability rules). -- [Timestamp and Date/Time Functions](timestamp_operations.md) - How to work with timestamps, dates, and times (e.g., extract parts, perform arithmetic, convert formats). -- [Enums](enum.md) - How to work with enums sqlgen - -## Data Types and Validation - -- [sqlgen::Dynamic](dynamic.md) - How to define custom SQL types not natively supported by sqlgen -- [sqlgen::ForeignKey](foreign_key.md) - How to establish referential integrity between tables -- [sqlgen::JSON](json.md) - How to store and work with JSON fields -- [sqlgen::Pattern](pattern.md) - How to add regex pattern validation to avoid SQL injection -- [sqlgen::Timestamp](timestamp.md) - How timestamps work in sqlgen -- [sqlgen::Unique](unique.md) - How to enforce uniqueness constraints on table columns -- [sqlgen::Varchar](varchar.md) - How varchars work in sqlgen - -## Other concepts - -- [Connection Pool](connection_pool.md) - How to manage database connections efficiently -- [Transactions](transactions.md) - How to use transactions for atomic operations -- [Views](views.md) - How to create and manage database views - -## Supported Databases - -- [DuckDB](duckdb.md) - How to interact with DuckDB -- [MySQL](mysql.md) - How to interact with MariaDB and MySQL -- [PostgreSQL](postgres.md) - How to interact with PostgreSQL and compatible databases (Redshift, Aurora, Greenplum, CockroachDB, ...) -- [SQLite](sqlite.md) - How to interact with SQLite3 - -For installation instructions, quick start guide, and usage examples, please refer to the [main README](../README.md). diff --git a/docs/content/_index.md b/docs/content/_index.md new file mode 100644 index 0000000..ce0b98a --- /dev/null +++ b/docs/content/_index.md @@ -0,0 +1,85 @@ +# sqlgen Documentation + +Welcome to the sqlgen documentation. This guide provides detailed information about sqlgen's features and APIs. + +![image](sqlgen.png) + +## Core Concepts + +{{< cards >}} + {{< card link="install" title="Installation" icon="book-open" subtitle="How to install sqlgen.">}} + {{< card link="defining_tables" title="Defining Tables" icon="book-open" subtitle="How to define tables using C++ structs.">}} + {{< card link="col" title="sqlgen::col" icon="book-open" subtitle="How to represent columns in queries.">}} + {{< card link="literals" title="sqlgen::literals" icon="book-open" subtitle="How to use column and table alias literals in queries.">}} + {{< card link="flatten" title="sqlgen::Flatten" icon="book-open" subtitle="How to "inherit" fields from other structs.">}} + {{< card link="primary_key" title="sqlgen::PrimaryKey" icon="book-open" subtitle="How to define primary keys in sqlgen.">}} + {{< card link="result" title="sqlgen::Result" icon="book-open" subtitle="How sqlgen handles errors and results.">}} + {{< card link="to_sql" title="sqlgen::to_sql" icon="book-open" subtitle="How to transpile C++ operations to dialect-specific SQL.">}} +{{}} + +## Database I/O + +{{< cards >}} + {{< card link="reading" title="sqlgen::read" icon="book-open" subtitle="How to read data from a database.">}} + {{< card link="writing" title="sqlgen::write" icon="book-open" subtitle="How to write data to a database.">}} +{{}} + +## Database Operations + +{{< cards >}} + {{< card link="create_as" title="sqlgen::create_as" icon="book-open" subtitle="How to create tables and views from SELECT queries.">}} + {{< card link="create_index" title="sqlgen::create_index" icon="book-open" subtitle="How to create an index on a table.">}} + {{< card link="create_table" title="sqlgen::create_table" icon="book-open" subtitle="How to create a new table.">}} + {{< card link="delete_from" title="sqlgen::delete_from" icon="book-open" subtitle="How to delete data from a table.">}} + {{< card link="drop" title="sqlgen::drop" icon="book-open" subtitle="How to drop a table.">}} + {{< card link="exec" title="sqlgen::exec" icon="book-open" subtitle="How to execute raw SQL statements.">}} + {{< card link="group_by_and_aggregations" title="sqlgen::group_by and Aggregations" icon="book-open" subtitle="How to generate GROUP BY queries and aggregate data.">}} + {{< card link="joins" title="sqlgen::inner_join, left_join, right_join, full_join" icon="book-open" subtitle="How to join different tables.">}} + {{< card link="insert" title="sqlgen::insert, insert_or_replace" icon="book-open" subtitle="How to insert data within transactions.">}} + {{< card link="select_from" title="sqlgen::select_from" icon="book-open" subtitle="How to read data from a database using more complex queries.">}} + {{< card link="unite" title="sqlgen::unite and unite_all" icon="book-open" subtitle="How to combine results from multiple SELECT statements.">}} + {{< card link="update" title="sqlgen::update" icon="book-open" subtitle="How to update data in a table.">}} +{{}} + +## Other Operations + +{{< cards >}} + {{< card link="cache" title="Cache" icon="book-open" subtitle="How to improve performance with caching.">}} + {{< card link="mathematical_operations" title="Mathematical Operations" icon="book-open" subtitle="How to use mathematical functions in queries (e.g., abs, ceil, floor, exp, trigonometric functions, round).">}} + {{< card link="string_operations" title="String Operations" icon="book-open" subtitle="How to manipulate and transform strings in queries (e.g., length, lower, upper, trim, replace, concat).">}} + {{< card link="type_conversion_operations" title="Type Conversion Operations" icon="book-open" subtitle="How to convert between types safely in queries (e.g., cast int to double).">}} + {{< card link="null_handling_operations" title="Null Handling Operations" icon="book-open" subtitle="How to handle nullable values and propagate nullability correctly (e.g., with coalesce and nullability rules).">}} + {{< card link="timestamp_operations" title="Timestamp and Date/Time Functions" icon="book-open" subtitle="How to work with timestamps, dates, and times (e.g., extract parts, perform arithmetic, convert formats).">}} + {{< card link="enum" title="Enums" icon="book-open" subtitle="How to work with enums in sqlgen.">}} +{{}} + +## Data Types and Validation + +{{< cards >}} + {{< card link="dynamic" title="sqlgen::Dynamic" icon="book-open" subtitle="How to define custom SQL types not natively supported by sqlgen.">}} + {{< card link="foreign_key" title="sqlgen::ForeignKey" icon="book-open" subtitle="How to establish referential integrity between tables.">}} + {{< card link="json" title="sqlgen::JSON" icon="book-open" subtitle="How to store and work with JSON fields.">}} + {{< card link="pattern" title="sqlgen::Pattern" icon="book-open" subtitle="How to add regex pattern validation to avoid SQL injection.">}} + {{< card link="timestamp" title="sqlgen::Timestamp" icon="book-open" subtitle="How timestamps work in sqlgen.">}} + {{< card link="unique" title="sqlgen::Unique" icon="book-open" subtitle="How to enforce uniqueness constraints on table columns.">}} + {{< card link="varchar" title="sqlgen::Varchar" icon="book-open" subtitle="How varchars work in sqlgen.">}} +{{}} + +## Other concepts + +{{< cards >}} + {{< card link="connection_pool" title="Connection Pool" icon="book-open" subtitle="How to manage database connections efficiently.">}} + {{< card link="transactions" title="Transactions" icon="book-open" subtitle="How to use transactions for atomic operations.">}} + {{< card link="views" title="Views" icon="book-open" subtitle="How to create and manage database views.">}} +{{}} + +## Supported Databases + +{{< cards >}} + {{< card link="duckdb" title="DuckDB" icon="book-open" subtitle="How to interact with DuckDB.">}} + {{< card link="mysql" title="MySQL" icon="book-open" subtitle="How to interact with MariaDB and MySQL.">}} + {{< card link="postgres" title="PostgreSQL" icon="book-open" subtitle="How to interact with PostgreSQL and compatible databases (Redshift, Aurora, Greenplum, CockroachDB, ...).">}} + {{< card link="sqlite" title="SQLite" icon="book-open" subtitle="How to interact with SQLite3.">}} +{{}} + +For installation instructions, quick start guide, and usage examples, please refer to the [main README](../README.md). diff --git a/docs/cache.md b/docs/content/cache.md similarity index 100% rename from docs/cache.md rename to docs/content/cache.md diff --git a/docs/col.md b/docs/content/col.md similarity index 100% rename from docs/col.md rename to docs/content/col.md diff --git a/docs/connection_pool.md b/docs/content/connection_pool.md similarity index 100% rename from docs/connection_pool.md rename to docs/content/connection_pool.md diff --git a/docs/create_as.md b/docs/content/create_as.md similarity index 100% rename from docs/create_as.md rename to docs/content/create_as.md diff --git a/docs/create_index.md b/docs/content/create_index.md similarity index 100% rename from docs/create_index.md rename to docs/content/create_index.md diff --git a/docs/create_table.md b/docs/content/create_table.md similarity index 100% rename from docs/create_table.md rename to docs/content/create_table.md diff --git a/docs/defining_tables.md b/docs/content/defining_tables.md similarity index 100% rename from docs/defining_tables.md rename to docs/content/defining_tables.md diff --git a/docs/delete_from.md b/docs/content/delete_from.md similarity index 100% rename from docs/delete_from.md rename to docs/content/delete_from.md diff --git a/docs/drop.md b/docs/content/drop.md similarity index 100% rename from docs/drop.md rename to docs/content/drop.md diff --git a/docs/duckdb.md b/docs/content/duckdb.md similarity index 100% rename from docs/duckdb.md rename to docs/content/duckdb.md diff --git a/docs/dynamic.md b/docs/content/dynamic.md similarity index 100% rename from docs/dynamic.md rename to docs/content/dynamic.md diff --git a/docs/enum.md b/docs/content/enum.md similarity index 100% rename from docs/enum.md rename to docs/content/enum.md diff --git a/docs/exec.md b/docs/content/exec.md similarity index 100% rename from docs/exec.md rename to docs/content/exec.md diff --git a/docs/flatten.md b/docs/content/flatten.md similarity index 100% rename from docs/flatten.md rename to docs/content/flatten.md diff --git a/docs/foreign_key.md b/docs/content/foreign_key.md similarity index 100% rename from docs/foreign_key.md rename to docs/content/foreign_key.md diff --git a/docs/group_by_and_aggregations.md b/docs/content/group_by_and_aggregations.md similarity index 100% rename from docs/group_by_and_aggregations.md rename to docs/content/group_by_and_aggregations.md diff --git a/docs/insert.md b/docs/content/insert.md similarity index 100% rename from docs/insert.md rename to docs/content/insert.md diff --git a/docs/content/install.md b/docs/content/install.md new file mode 100644 index 0000000..4f42f9d --- /dev/null +++ b/docs/content/install.md @@ -0,0 +1,79 @@ +# Installation + +## Quick Start + +### Install using vcpkg or Conan + +You can install the latest release of sqlgen +using either [vcpkg](https://vcpkg.io/en/package/sqlgen) or [Conan](https://conan.io/center/recipes/sqlgen). + +### Build using vcpkg + +Alternatively, you can build sqlgen from source using vcpkg: + +1. Make sure you have the required dependencies installed (skip this step on Windows): +```bash +sudo apt-get install autoconf bison flex # Linux (Ubuntu, Debian, ...) +brew install autoconf bison flexΒ # macOS +``` + +2. Set up vcpkg: +```bash +git submodule update --init +./vcpkg/bootstrap-vcpkg.sh # Linux, macOS +./vcpkg/bootstrap-vcpkg.bat # Windows +``` + +3. Build the library: +```bash +cmake -S . -B build -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release +cmake --build build -j 4 # gcc, clang +cmake --build build --config Release -j 4 # MSVC +``` + +This will build the static library. To build the shared library +add `-DBUILD_SHARED_LIBS=ON -DVCPKG_TARGET_TRIPLET=...` to the first line. +Run `./vcpkg/vcpkg help triplets` to view all supported triplets. +Common triplets for shared libraries are `x64-linux-dynamic`, +`arm64-osx-dynamic` or `x64-osx-dynamic`. + +Add `-DSQLGEN_MYSQL=ON` to support MySQL/MariaDB. Add `-DSQLGEN_DUCKDB=ON` to support DuckDB. + +4. Include in your CMake project: +```cmake +find_package(sqlgen REQUIRED) +target_link_libraries(your_target PRIVATE sqlgen::sqlgen) +``` + +### Build using Conan + +You can also build sqlgen from source using Conan: + +1. Install Conan (assuming you have Python and pipx installed): + +```bash +pipx install conan +conan profile detect +``` + +For older versions of pip, you can also use `pip` instead of `pipx`. + +2. Build the library: + +```bash +conan build . --build=missing -s compiler.cppstd=gnu20 +``` + +This will build the static library. To build the shared library, +add `-o */*:shared=True`. + +Add `-o sqlgen/*:with_mysql=True` to support MySQL/MariaDB. + +3. Include in your CMake project: +```cmake +find_package(sqlgen REQUIRED) +target_link_libraries(your_target PRIVATE sqlgen::sqlgen) +``` + +You can call `conan inspect .` to get an overview of the supported options. + diff --git a/docs/joins.md b/docs/content/joins.md similarity index 100% rename from docs/joins.md rename to docs/content/joins.md diff --git a/docs/json.md b/docs/content/json.md similarity index 100% rename from docs/json.md rename to docs/content/json.md diff --git a/docs/literals.md b/docs/content/literals.md similarity index 100% rename from docs/literals.md rename to docs/content/literals.md diff --git a/docs/mathematical_operations.md b/docs/content/mathematical_operations.md similarity index 100% rename from docs/mathematical_operations.md rename to docs/content/mathematical_operations.md diff --git a/docs/mysql.md b/docs/content/mysql.md similarity index 100% rename from docs/mysql.md rename to docs/content/mysql.md diff --git a/docs/null_handling_operations.md b/docs/content/null_handling_operations.md similarity index 100% rename from docs/null_handling_operations.md rename to docs/content/null_handling_operations.md diff --git a/docs/pattern.md b/docs/content/pattern.md similarity index 100% rename from docs/pattern.md rename to docs/content/pattern.md diff --git a/docs/postgres.md b/docs/content/postgres.md similarity index 100% rename from docs/postgres.md rename to docs/content/postgres.md diff --git a/docs/primary_key.md b/docs/content/primary_key.md similarity index 100% rename from docs/primary_key.md rename to docs/content/primary_key.md diff --git a/docs/reading.md b/docs/content/reading.md similarity index 100% rename from docs/reading.md rename to docs/content/reading.md diff --git a/docs/result.md b/docs/content/result.md similarity index 100% rename from docs/result.md rename to docs/content/result.md diff --git a/docs/select_from.md b/docs/content/select_from.md similarity index 100% rename from docs/select_from.md rename to docs/content/select_from.md diff --git a/docs/content/sqlgen.png b/docs/content/sqlgen.png new file mode 100644 index 0000000..16da9a5 Binary files /dev/null and b/docs/content/sqlgen.png differ diff --git a/docs/sqlite.md b/docs/content/sqlite.md similarity index 100% rename from docs/sqlite.md rename to docs/content/sqlite.md diff --git a/docs/string_operations.md b/docs/content/string_operations.md similarity index 100% rename from docs/string_operations.md rename to docs/content/string_operations.md diff --git a/docs/timestamp.md b/docs/content/timestamp.md similarity index 100% rename from docs/timestamp.md rename to docs/content/timestamp.md diff --git a/docs/timestamp_operations.md b/docs/content/timestamp_operations.md similarity index 100% rename from docs/timestamp_operations.md rename to docs/content/timestamp_operations.md diff --git a/docs/to_sql.md b/docs/content/to_sql.md similarity index 100% rename from docs/to_sql.md rename to docs/content/to_sql.md diff --git a/docs/transactions.md b/docs/content/transactions.md similarity index 100% rename from docs/transactions.md rename to docs/content/transactions.md diff --git a/docs/type_conversion_operations.md b/docs/content/type_conversion_operations.md similarity index 100% rename from docs/type_conversion_operations.md rename to docs/content/type_conversion_operations.md diff --git a/docs/unique.md b/docs/content/unique.md similarity index 100% rename from docs/unique.md rename to docs/content/unique.md diff --git a/docs/unite.md b/docs/content/unite.md similarity index 100% rename from docs/unite.md rename to docs/content/unite.md diff --git a/docs/update.md b/docs/content/update.md similarity index 100% rename from docs/update.md rename to docs/content/update.md diff --git a/docs/varchar.md b/docs/content/varchar.md similarity index 100% rename from docs/varchar.md rename to docs/content/varchar.md diff --git a/docs/views.md b/docs/content/views.md similarity index 100% rename from docs/views.md rename to docs/content/views.md diff --git a/docs/writing.md b/docs/content/writing.md similarity index 100% rename from docs/writing.md rename to docs/content/writing.md diff --git a/docs/go.mod b/docs/go.mod new file mode 100644 index 0000000..f75b3bd --- /dev/null +++ b/docs/go.mod @@ -0,0 +1,5 @@ +module github.com/imfing/hextra-starter-template + +go 1.26 + +require github.com/imfing/hextra v0.12.3 // indirect diff --git a/docs/go.sum b/docs/go.sum new file mode 100644 index 0000000..afa8680 --- /dev/null +++ b/docs/go.sum @@ -0,0 +1,2 @@ +github.com/imfing/hextra v0.12.3 h1:DZHY2rUWYteyzjlHi9r4n7Bb5e2Q+6LXe4C1Dqn0ZjM= +github.com/imfing/hextra v0.12.3/go.mod h1:vi+yhpq8YPp/aghvJlNKVnJKcPJ/VyAEcfC1BSV9ARo= diff --git a/docs/hugo.yaml b/docs/hugo.yaml new file mode 100644 index 0000000..7240a1e --- /dev/null +++ b/docs/hugo.yaml @@ -0,0 +1,41 @@ +# Hugo configuration file +title: sqlgen + +# import hextra as module +module: + imports: + - path: github.com/imfing/hextra + +markup: + # allow raw html + goldmark: + renderer: + unsafe: true + + # enable hextra syntax highlight + highlight: + noClasses: false + +menu: + main: + - name: Main Page + pageRef: / + weight: 1 + - name: Search + weight: 2 + params: + type: search + - name: GitHub + weight: 3 + url: "https://github.com/getml/sqlgen/" + params: + icon: github + +params: + navbar: + displayTitle: true + displayLogo: false + + footer: + displayCopyright: false + displayPoweredBy: true