Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikeblum/sqlite-koans
code for SQLite Koans post
https://github.com/mikeblum/sqlite-koans
database golang sqlite sqlite3 template-project
Last synced: 15 days ago
JSON representation
code for SQLite Koans post
- Host: GitHub
- URL: https://github.com/mikeblum/sqlite-koans
- Owner: mikeblum
- License: mit
- Created: 2023-01-22T02:38:26.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-29T18:06:10.000Z (almost 2 years ago)
- Last Synced: 2024-10-11T05:43:48.332Z (about 1 month ago)
- Topics: database, golang, sqlite, sqlite3, template-project
- Language: Go
- Homepage: https://mblum.me/2023/01/sqlite-koans
- Size: 31.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SQLite Koans
Companion code for [SQLite Koans](https://mblum.me/2023/01/sqlite-koans/)
This project configures `sqlite3` for real world apps:
✅ Foreign Keys
✅ Read as you Write
✅ Write-Ahead Logging
✅ `UTF-8` encoding
✅ graceful table lock error handling via `PRAGMA busy_timeout;`
✅ No empty or `null` primary keys
✅ WAL backup via checkpointing
The repo has a commit covering each koan that we tie to a particular `PRAGMA` config flag:
[SQLite PRAGMA](https://www.sqlite.org/pragma.html)
## Depends On
[SQLite Version 3.40.1](https://www.sqlite.org/releaselog/3_40_1.html)
> Ubuntu apt version is outdated on both Ubuntu 20 and 22
## Build SQLite from source
1\. Install Build Tools
> `gcc` is required for `CGO` bindings used by `mattn/go-sqlite3`
`sudo apt-get install build-essential gcc`
1a\. confirm `gcc` installation
`gcc --version`
2\. Install latest SQLite snapshot (~v3.40.1 minimum)
```
export SQLITE_SNAPSHOT=202301131932
wget "https://www.sqlite.org/snapshot/sqlite-snapshot-${SQLITE_SNAPSHOT}.tar.gz"
tar -xzvf sqlite-snapshot-$SQLITE_SNAPSHOT.tar.gz
cd sqlite-snapshot-$SQLITE_SNAPSHOT
./configure
make
sudo make install
```3\. Verify `sqlite3` install
```
❯ sqlite3
SQLite version 3.40.2 2023-01-13 19:32:19
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite>
```