diff --git a/main.py b/main.py index f4c8255..1fa1655 100644 --- a/main.py +++ b/main.py @@ -72,7 +72,7 @@ def process_gpx_files(tx: Connection): owner = os.path.split(filepath)[-1].split('_workout-')[0] filename = f'workout-{os.path.split(filepath)[-1].split("_workout-")[1]}' print(f'Processing {filename}') - if list(db.execute(text('select exists(select from training where owner = :owner and filename = :filename)'), + if list(tx.execute(text('select exists(select from training where owner = :owner and filename = :filename)'), dict(owner=owner, filename=filename,),),)[0][0]: os.remove(filepath) continue @@ -80,7 +80,7 @@ def process_gpx_files(tx: Connection): gpx_file = gpxpy.parse(f) if gpx_file.creator != 'FitoTrack': raise ValueError('gpx file not generated by the FitoTrack app') - training_id = list(db.execute( + training_id = list(tx.execute( text(""" insert into training(owner, filename, type, description, moving_time, stopped_time, moving_distance, stopped_distance) values (:owner, :filename, :type, :description, :moving_time, :stopped_time, :moving_distance, :stopped_distance) returning id @@ -97,7 +97,7 @@ def process_gpx_files(tx: Connection): for track in gpx_file.tracks: for segment in track.segments: for point in segment.points: - db.execute(text(""" + tx.execute(text(""" insert into training_data(training_id, t, geog, speed, elevation) values (:training_id, :t, :geog, :speed, :elevation) """),