working on slides

This commit is contained in:
thomashamburg 2025-10-13 17:37:55 +02:00
parent e9bd14c96d
commit 4631fe3d88
2 changed files with 102 additions and 2 deletions

View File

@ -0,0 +1,35 @@
# Features of the `sqlite` Go Package
This is a summary of the key features provided by the `sqlite` package, based on an analysis of `database.go`.
* **Simplified Database Lifecycle Management**:
* Provides straightforward functions to `New`, `Open`, `OpenInMemory`, and `Close` SQLite databases.
* Automatically creates a new database file if one doesn't exist, pre-configured with performance-oriented `PRAGMA` settings like `WAL` (Write-Ahead Logging) mode.
* **Generic Data Handling**:
* Uses a `Record` type (`map[string]any`) to represent database rows, allowing for flexible interaction with tables without needing to define a struct for each one.
* **High-Level CRUD Operations**:
* Offers simple methods for common database tasks:
* `ReadRecords`: Execute any `SELECT` query with parameters.
* `GetRecord`: Fetch a single record by its key.
* `UpsertRecord`: A powerful function to either `INSERT` a new record or `UPDATE` an existing one if a conflict on the primary key occurs. This is handled atomically in the database using `INSERT ... ON CONFLICT`.
* `DeleteRecord`: Remove a record by its key.
* **Fluent Transaction API**:
* Implements a chainable transaction interface that simplifies running multiple operations in a single transaction.
* Example: `db.Begin().Next(action1).Next(action2).End()`
* The `End()` method automatically commits on success or rolls back if any step in the chain fails, ensuring data integrity.
* **Database Introspection**:
* Includes helper functions to query database metadata, such as `TableList()` to get all table names, `Version()` for the SQLite engine version, and `UserVersion()` to manage schema versions.
* **Abstraction and Safety**:
* Abstracts away the boilerplate of `database/sql` row scanning into `Rows2record` and `Rows2records` helpers.
* Uses parameterized queries to prevent SQL injection vulnerabilities for data values.
* **Utility Functions**:
* Provides a generic `Value` function to safely extract and type-assert a value from a `Record`.
* Includes a `NoRowsOk` helper to gracefully handle queries that are expected to sometimes return no results, preventing "no rows found" from being treated as a critical error.
This package is designed as a high-level wrapper around Go's standard `database/sql` library, specifically tailored for SQLite to make common database operations more convenient and less error-prone.

View File

@ -128,10 +128,75 @@ transition: fade-out
- Part 1: The Database: SQLite
- Part 2: The No-ORM ORM - A very simple Data Abstraction Layer.
- Part 3: Developing a Web Server Application in Go.
- Part 4: Datastar - lightweight framework for real-time collaborative web apps.
- Part 4: Datastar - a lightweight framework for real-time collaborative web apps.
- Part 5: Modern CSS.
- Part 6: Web components.
- Part 7: Simple Deployments with VPS, Nginx, certbot and a single binary file.
- Part 7: Simple Deployments with a VPS, Nginx, Certbot and a single binary file.
---
class: default
transition: fade-out
---
# Part 1: SQLite:
### It is fast, feature complete* and rock solid.
<div class="mt-10"/>
## It is not SQ-Lite, it is SQL-ite
Since everybody knows SQLite, today just a few highlights:
- It has JSON and JSONB as built-in data types.
- It has 29 new functions to extract from JSON or to create JSON objects.
- It's CTEs make SQL Turing complete.
- The SQLite CLI can be used to execute "SQL-scripts". See demo.
<div class="mt-40"/>
<div> * from my pov and for my needs and purposes</div>
---
class: default
transition: fade-out
---
# Part 2: A very simple Data Abstraction Layer:
<div class="mt-10"/>
Features:
- Simplified Database Lifecycle Management.
- Generic Data Handling.
- High-Level CRUD Operations.
- Fluent Transaction API.
- Database Introspection.
- Abstraction and Safety.
- Utility Functions.
<div class="mt-40"/>
---
class: default
transition: fade-out
---
# Part 3: Developing a Web Server Application in Go.
<div class="mt-10"/>
Why Go?
- Go is a compiled language that generates native machine code.
- Generic Data Handling.
- High-Level CRUD Operations.
- Fluent Transaction API.
- Database Introspection.
- Abstraction and Safety.
- Utility Functions.
<div class="mt-40"/>
---
class: default
---