Examples
Practical examples for DB usage with MySQL, PostgreSQL, Scylla, and shared database helpers.
Practical examples are available in the official examples repository:
https://github.com/netlifeguru/examples/dbThe repository contains standalone examples covering connection setup, connection configuration, connection pools, typed queries, pointer-based lookups, maps, scalar values, inserts, updates, deletes, dialect SQL, low-level operations, transactions, SQL files, Scylla batches, and lightweight transactions.
MySQL Examples
MySQL examples are available at:
https://github.com/netlifeguru/examples/db/mysqlThese examples demonstrate the shared DB API with the MySQL driver, including ? placeholders, LastInsertId, dialect SQL, SQL transactions, connection pools, and multi-driver SQL files.
Getting Started and Connections
Select Helpers
Query Object Helpers
Dialect SQL Helpers
Mutations
Low-Level Mutations
Transactions and SQL Files
PostgreSQL Examples
PostgreSQL examples are available at:
https://github.com/netlifeguru/examples/db/postgresqlThese examples demonstrate the shared DB API with the PostgreSQL driver, including numbered placeholders, INSERT ... RETURNING, dialect SQL, connection pools, SQL transactions, and multi-driver SQL files.
Getting Started and Connections
Select Helpers
Query Object Helpers
Dialect SQL Helpers
Mutations
Low-Level Mutations
Transactions and SQL Files
Scylla Examples
Scylla examples are available at:
https://github.com/netlifeguru/examples/db/scyllaThese examples demonstrate the shared DB API with the Scylla driver, including CQL placeholders, connection pools, query-driven tables, generated IDs, batches, lightweight transactions, and CQL model files.
Getting Started and Connections
Select Helpers
Query Object Helpers
Dialect SQL Helpers
Mutations
Low-Level Mutations
Batches
Lightweight Transactions
SQL Files
Recommended Starting Points
Start with the getting-started example for your driver:
Continue with connection configuration and connection pools:
02_connection03_connection_config04_connection_pools
Then explore the shared select helpers:
05_select_list06_select_get07_select_get_ptr08_select_value09_select_map
For prepared db.Query values, continue with:
10_query_list11_query-get12_query-get_ptr13_query_value14_query_map
For SQL loaded through db.DialectSQL, continue with:
15_dialect_list16_dialect_get17_dialect_get_ptr18_dialect_valueor18_dialect_map, depending on the driver19_dialect_mapor19_dialect_value, depending on the driver
For mutation helpers, see the insert, update, delete, and dialect mutation examples for the selected driver.
For lower-level control, continue with the low-level mutation and transaction examples.