· 7 years ago · Feb 02, 2019, 12:56 PM
1 database_curser.execute(
2 'CREATE TABLE IF NOT EXISTS ' + table_data + ' (' +
3 'id INTEGER PRIMARY KEY AUTOINCREMENT,' + # enrty ID
4 'user INTEGER,' + # Telegram ID, who refueld the car
5 'car VARCHAR(100)' + # here we use the FIN (the id in the cars-table)
6 'date TIMESTAMP,' +
7 'amount REAL,' + # value in liter
8 'costs REAL,' + # value in currency
9 'fuel_type VARCHAR(50),' + # the name of the fuel-table
10 'gas_station VARCHAR(50),' + # the name of the stations-table
11 'picture BLOB)') # a picture of the bill
12 database_curser.execute('CREATE TABLE IF NOT EXISTS ' + table_cars + ' (' +
13 'fin VARCHAR(100) UNIQUE,' + # we use the 'Fahrzeug Identifikationsnummer' as unique value
14 'owner INTEGER,' + # again, we use the Telegram ID to identify the owner/user
15 'license_plate VARCHAR(50)' +
16 'brand VARCHAR(100),' +
17 'name VARCHAR(100),' +
18 'type VARCHAR(100),' +
19 'color VARCHAR(50),' +
20 'fuel_type VARCHAR(50),' + # the family from the fuel-table
21 'total_costs REAL' + # value in currency
22 'total_consumption REAL' + # value in liter
23 'avarage_consumption REAL' + # value in liter
24 'picture BLOB)')
25 database_curser.execute('CREATE TABLE IF NOT EXISTS ' + table_users + ' (' +
26 'user INTEGER UNIQUE,' + # Telegram ID
27 'forename VARCHAR(100),' +
28 'name VARCHAR(100)' +
29 'preferred_car VARCHAR(100))') # the FIN from the cars-table
30 database_curser.execute('CREATE TABLE IF NOT EXISTS ' + table_fuel + ' (' +
31 'name VARCHAR(50) UNIQUE,' + # Diesel, Petrol, etc
32 'family VARCHAR(50))')
33 database_curser.execute('CREATE TABLE IF NOT EXISTS ' + table_stations + ' (' +
34 'name VARCHAR(50) UNIQUE)')
35 database_init.commit()