Use mnemonic names.

This commit is contained in:
King_DuckZ 2020-02-27 14:37:05 +01:00
parent fd7e3e6324
commit 7ba637b6a4

View file

@ -33,8 +33,12 @@ private void insert_into_sqlite(sqlite3* db, string path) {
// Expected CSV format: title,edition,version,languages,serial,region
foreach (record; file.byLine.joiner("\n").csvReader!(Tuple!(string, string, string, string, string, string))) {
const int ver = cast(int)((record[2].empty ? 0.0 : to!double(record[2])) * 100.0);
const int region = 0;
string[] serials = record[4].split(";");
string languages = record[3];
string edition = record[1];
string title = record[0];
string region = record[5];
const int region_id = 0;
foreach (serial; serials) {
serial = serial.strip;
@ -43,13 +47,16 @@ private void insert_into_sqlite(sqlite3* db, string path) {
}
serials_seen[serial] = false;
sqlite3_bind_text(statement, 1, record[0].ptr, cast(int)record[0].length, SQLITE_STATIC); //title
sqlite3_bind_text(statement, 2, record[1].ptr, cast(int)record[1].length, SQLITE_STATIC); //edition
sqlite3_bind_text(statement, 1, title.ptr, cast(int)title.length, SQLITE_STATIC); //title
sqlite3_bind_text(statement, 2, edition.ptr, cast(int)edition.length, SQLITE_STATIC); //edition
sqlite3_bind_double(statement, 3, ver); //version
sqlite3_bind_text(statement, 4, record[3].ptr, cast(int)record[3].length, SQLITE_STATIC); //languages
if (!languages.empty)
sqlite3_bind_text(statement, 4, languages.ptr, cast(int)languages.length, SQLITE_STATIC); //languages
else
sqlite3_bind_null(statement, 4);
sqlite3_bind_text(statement, 5, serial.ptr, cast(int)serial.length, SQLITE_STATIC); //serial
sqlite3_bind_int(statement, 6, region); //region
stderr.writefln("insert into: \"%s\", \"%s\", \"%d\", \"%s\", \"%s\", \"%d\"", record[0], record[1], ver, record[3], serial, region);
sqlite3_bind_int(statement, 6, region_id); //region
stderr.writefln("insert into: \"%s\", \"%s\", \"%d\", \"%s\", \"%s\", \"%d\"", record[0], record[1], ver, record[3], serial, region_id);
const int step_ret = sqlite3_step(statement);
if (step_ret && SQLITE_DONE != step_ret)