Skip to content

Commit

Permalink
Insert more than one row
Browse files Browse the repository at this point in the history
  • Loading branch information
MancunianSam committed Dec 12, 2024
1 parent 76e4d1d commit 41e9b1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions .github/scripts/generate_index_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@ def get_json_files(prefix):
json_files = get_json_files('fmt') + get_json_files('x-fmt')


def insert_into_indexes(path_value: str, field_name: str, field_value: str):
def create_table():
conn = sqlite3.connect("indexes")
try:
cursor = conn.cursor()
cursor.execute("DROP TABLE IF EXISTS indexes")
cursor.execute("CREATE TABLE IF NOT EXISTS indexes (path, name, field)")
conn.commit()
except sqlite3.Error as e:
print(f"An error occurred: {e}")
finally:
conn.close()


def insert_into_indexes(path_value: str, field_name: str, field_value: str):
conn = sqlite3.connect("indexes")
try:
cursor = conn.cursor()
cursor.execute("INSERT INTO indexes (path, name, field) VALUES (?, ?, ?)",
(path_value, field_name, field_value))

Expand All @@ -30,11 +41,12 @@ def insert_into_indexes(path_value: str, field_name: str, field_value: str):


for file_path in json_files:
create_table()
with open(f'{path}/signatures/{file_path}', 'r') as file:
data_values = []
data = json.load(file)
format_name = data['formatName']
puid = [identifier['identifierText'] for identifier in data['identifiers'] if identifier['identifierType'] == 'PUID'][0]
puid = [idf['identifierText'] for idf in data['identifiers'] if idf['identifierType'] == 'PUID'][0]
for value in data.values():
if type(value) is list:
for each in value:
Expand Down
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
{
'text': "Signature Files",
'href': "/signature_files.html"
'href': "/signature_list.html"
}
]
}) }}
Expand Down

0 comments on commit 41e9b1e

Please sign in to comment.