-
Notifications
You must be signed in to change notification settings - Fork 0
/
bs4dumpvdl2.sql
42 lines (42 loc) · 1.14 KB
/
bs4dumpvdl2.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
PRAGMA foreign_keys=OFF;
PRAGMA synchronous=OFF;
BEGIN TRANSACTION;
CREATE TEMP TABLE _csv_import(
"icao24" TEXT,
"registration" TEXT,
"manufacturericao" TEXT,
"manufacturername" TEXT,
"model" TEXT,
"typecode" TEXT,
"serialnumber" TEXT,
"linenumber" TEXT,
"icaoaircrafttype" TEXT,
"operator" TEXT,
"operatorcallsign" TEXT,
"operatoricao" TEXT,
"operatoriata" TEXT,
"owner" TEXT,
"testreg" TEXT,
"registered" TEXT,
"reguntil" TEXT,
"status" TEXT,
"built" TEXT,
"firstflightdate" TEXT,
"seatconfiguration" TEXT,
"engines" TEXT,
"modes" TEXT,
"adsb" TEXT,
"acars" TEXT,
"notes" TEXT,
"categoryDescription" TEXT
);
.mode csv
.separator ","
.import aircraftDatabaseu.csv _csv_import
DROP TABLE IF EXISTS Aircraft;
CREATE TABLE Aircraft(ModeS CHAR(6) UNIQUE PRIMARY KEY, Registration, ICAOTypeCode, OperatorFlagCode, Manufacturer, Type, RegisteredOwners);
INSERT OR IGNORE INTO Aircraft SELECT icao24, registration, typecode, operatoricao, manufacturericao, REPLACE(model,"'", '`'), REPLACE(REPLACE(owner, X'0A', ' '),"'", '`')
FROM _csv_import WHERE registration!='' ORDER BY icao24;
DROP TABLE _csv_import;
COMMIT;
.exit