Documentation
¶
Overview ¶
Package sqlite writes the extracted tables to wowsims.db: the schema (one table per .dbd definition, arrays as JSON text plus generated per-element columns) and the row inserts. This file is the schema half.
The writer uses zombiezen.com/go/sqlite (the same pure-Go modernc engine gen_db reads with, minus database/sql) because its prepared statements are persistent: the modernc database/sql driver re-parses the SQL text on every Exec, which made the wide per-row upserts dominate the whole extraction (~40s of a ~42s run; prepare-once brings that to ~7s).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTables ¶
CreateTables emits the schema for every table, in order, inside one transaction.
func InsertRows ¶
InsertRows upserts every decoded row of one table inside one transaction, through a single prepared statement (prepare once, bind/step/reset per row — see the package comment for why this matters).
Contract notes (the wowsims.db output format):
- definition order = column order = bind order;
- relation-column idx_ indexes use table-less names (idx_<col lowercased>) with IF NOT EXISTS, so only the first table processed with a given relation-column name gets the index — tables MUST be processed in settings order;
- relation values of 0 stay 0, never NULLed;
- arrays serialize as JSON text via encoding/json over plain numeric slices (u8 arrays emit [0,0,0], never base64);
- float scalars bind as the double-widened float32.
func Open ¶
Open deletes any pre-existing database file — every run starts from an empty file, which is what makes post-patch re-runs and db/ptrdb alternation correct — and opens a fresh connection with PRAGMA foreign_keys = ON.
The journal and sync pragmas trade durability for speed: the file is a regenerated build artifact, so a run that dies mid-write is repaired by the next run's delete-and-rebuild, never by rollback or fsync.
Types ¶
type TableDef ¶
type TableDef struct {
Name string
Def dbd.DBDefinition
Version dbd.VersionDefinitions
}
TableDef pairs a table name with its parsed definition and the version block selected for the current build (the caller selects once and both schema and inserts use the same block).