Fix database

This commit is contained in:
Cédric Leporcq 2022-04-23 18:40:34 +02:00
parent 503b90b631
commit f8ae11c57f
2 changed files with 11 additions and 6 deletions

View File

@ -310,7 +310,9 @@ class Sqlite:
value = None value = None
self.cur.execute('SELECT * FROM location') self.cur.execute('SELECT * FROM location')
for row in self.cur: for row in self.cur:
distance = distance_between_two_points(latitude, longitude, row[0], row[1]) distance = distance_between_two_points(
latitude, longitude, row['Latitude'], row['Longitude']
)
# Use if closer then threshold_km reuse lookup # Use if closer then threshold_km reuse lookup
if distance < shorter_distance and distance <= threshold_m: if distance < shorter_distance and distance <= threshold_m:
shorter_distance = distance shorter_distance = distance

View File

@ -28,7 +28,7 @@ class TestSqlite:
'CameraMake': 'camera_make', 'CameraMake': 'camera_make',
'CameraModel': 'camera_model', 'CameraModel': 'camera_model',
'OriginalName':'original_name', 'OriginalName':'original_name',
'SrcPath': 'src_path', 'SrcDir': 'src_dir',
'Subdirs': 'subdirs', 'Subdirs': 'subdirs',
'Filename': 'filename' 'Filename': 'filename'
} }
@ -44,8 +44,8 @@ class TestSqlite:
'Location': 'location' 'Location': 'location'
} }
cls.sqlite.add_row('metadata', row_data) cls.sqlite.upsert_metadata(row_data)
cls.sqlite.add_row('location', location_data) cls.sqlite.upsert_location(location_data)
# cls.sqlite.add_metadata_data('filename', 'ksinslsdosic', 'original_name', 'date_original', 'album', 1) # cls.sqlite.add_metadata_data('filename', 'ksinslsdosic', 'original_name', 'date_original', 'album', 1)
# cls.sqlite.add_location(24.2, 7.3, 'city', 'state', 'country', 'location') # cls.sqlite.add_location(24.2, 7.3, 'city', 'state', 'country', 'location')
@ -66,6 +66,7 @@ class TestSqlite:
result = tuple(self.sqlite.cur.execute("""select * from metadata where result = tuple(self.sqlite.cur.execute("""select * from metadata where
rowid=1""").fetchone()) rowid=1""").fetchone())
assert result == ( assert result == (
1,
'file_path', 'file_path',
'checksum', 'checksum',
'album', 'album',
@ -79,7 +80,7 @@ class TestSqlite:
'camera_make', 'camera_make',
'camera_model', 'camera_model',
'original_name', 'original_name',
'src_path', 'src_dir',
'subdirs', 'subdirs',
'filename' 'filename'
) )
@ -96,7 +97,9 @@ class TestSqlite:
result = tuple(self.sqlite.cur.execute("""select * from location where result = tuple(self.sqlite.cur.execute("""select * from location where
rowid=1""").fetchone()) rowid=1""").fetchone())
assert result == ( assert result == (
24.2, 7.3, 1,
24.2,
7.3,
'latitude_ref', 'latitude_ref',
'longitude_ref', 'longitude_ref',
'city', 'city',