Create a file at `path` (or overwrite it) and associate it with `db`
| 334 | |
| 335 | /// Create a file at `path` (or overwrite it) and associate it with `db` |
| 336 | static bool create_db(QSqlDatabase* db) |
| 337 | { |
| 338 | const auto create_nodes = "CREATE TABLE Nodes( \ |
| 339 | NodeID INTEGER PRIMARY KEY, \ |
| 340 | ParentID int NOT NULL, \ |
| 341 | Alternative int NOT NULL, \ |
| 342 | NKids int NOT NULL, \ |
| 343 | Status int, \ |
| 344 | Label varchar(256) \ |
| 345 | );"; |
| 346 | |
| 347 | const auto create_bookmarks = "Create TABLE Bookmarks( \ |
| 348 | NodeID INTEGER PRIMARY KEY, \ |
| 349 | Bookmark varchar(8) \ |
| 350 | );"; |
| 351 | |
| 352 | const auto create_nogoods = "CREATE TABLE Nogoods( \ |
| 353 | NodeID INTEGER PRIMARY KEY, \ |
| 354 | Nogood varchar(8) \ |
| 355 | );"; |
| 356 | |
| 357 | const auto create_info = "CREATE TABLE Info( \ |
| 358 | NodeID INTEGER PRIMARY KEY, \ |
| 359 | Info TEXT \ |
| 360 | );"; |
| 361 | |
| 362 | QSqlQuery query (*db); |
| 363 | |
| 364 | if(!query.exec(create_nodes)) return false; |
| 365 | if(!query.exec(create_bookmarks)) return false; |
| 366 | if(!query.exec(create_nogoods)) return false; |
| 367 | if(!query.exec(create_info)) return false; |
| 368 | |
| 369 | return true; |
| 370 | } |
| 371 | |
| 372 | /// this takes (without nogoods) under 2 sec for a ~1.5M nodes (golomb 10) |
| 373 | void save_execution(const Execution *ex, const char *path) |