kopia lustrzana https://github.com/glidernet/ogn-python
Move constraint disabling/enabling from import function to index disabling/enabling functions
rodzic
11ded87599
commit
00b68ee818
|
@ -120,6 +120,12 @@ def drop_indices():
|
|||
""")
|
||||
print("Dropped indices of AircraftBeacon")
|
||||
|
||||
# disable constraint trigger
|
||||
session.execute("""
|
||||
ALTER TABLE aircraft_beacons DISABLE TRIGGER ALL
|
||||
""")
|
||||
print("Disabled constraint triggers")
|
||||
|
||||
|
||||
@manager.command
|
||||
def create_indices():
|
||||
|
@ -133,6 +139,11 @@ def create_indices():
|
|||
""")
|
||||
print("Created indices for AircraftBeacon")
|
||||
|
||||
session.execute("""
|
||||
ALTER TABLE aircraft_beacons ENABLE TRIGGER ALL
|
||||
""")
|
||||
print("Enabled constraint triggers")
|
||||
|
||||
|
||||
@manager.command
|
||||
def import_csv_logfile(path, logfile='main.log', loglevel='INFO'):
|
||||
|
@ -267,12 +278,6 @@ def import_aircraft_beacon_logfile(csv_logfile):
|
|||
""")
|
||||
print("Inserted missing Receivers")
|
||||
|
||||
# disable constraint trigger
|
||||
session.execute("""
|
||||
ALTER TABLE aircraft_beacons DISABLE TRIGGER ALL
|
||||
""")
|
||||
print("Disabled constraint triggers")
|
||||
|
||||
session.execute("""
|
||||
INSERT INTO aircraft_beacons(location, altitude, name, receiver_name, timestamp, track, ground_speed,
|
||||
address_type, aircraft_type, stealth, address, climb_rate, turn_rate, flightlevel, signal_quality, error_count, frequency_offset, gps_status, software_version, hardware_version, real_address, signal_power,
|
||||
|
@ -285,11 +290,6 @@ def import_aircraft_beacon_logfile(csv_logfile):
|
|||
""")
|
||||
print("Wrote AircraftBeacons from temporary table into final table")
|
||||
|
||||
session.execute("""
|
||||
ALTER TABLE aircraft_beacons ENABLE TRIGGER ALL
|
||||
""")
|
||||
print("Enabled constraint triggers")
|
||||
|
||||
session.execute("""DROP TABLE aircraft_beacons_temp""")
|
||||
print("Dropped temporary table")
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue