ldo/ShaderTools — comment on commit 2438d8ac3ee32ba48207e4b37132a925875d48ec
File:  line 0
By ldo:

Notice I omit any explicit setting of the primary key fields (e.g. Mat_Index, Tex_Index) in the new records I am inserting. In SQLite3, these are automatically taken as auto-increment fields, which means that SQLite will assign the next available unique value when inserting the record. However, I need the assigned value from a parent record so I can put that into associated child records; thus, each texture record has a Mat_Idx field which must match the Mat_Index value for the associated material. Conveniently, I can get this value from SQLite with a simple query, which is encapsulated in the LastInsertID function: call it immediately inserting a record, and it will return the assigned key value for that record.