Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -182,10 +182,16 @@ def collect_files(conn, cursor, directory, pattern):
|
|
182 |
|
183 |
return array
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
def insert_data(conn, cursor, name, ids_array):
|
186 |
cursor.execute('INSERT INTO table_names (doc_name) VALUES (?)', (name,))
|
187 |
for ids in ids_array:
|
188 |
-
cursor.execute('INSERT INTO table_ids (name, ids_value) VALUES (?, ?)', (name, ids))
|
189 |
conn.commit()
|
190 |
|
191 |
@st.cache_resource(show_spinner=False)
|
@@ -278,7 +284,7 @@ def load_models_and_documents():
|
|
278 |
cursor.execute('''
|
279 |
CREATE TABLE table_ids (
|
280 |
name TEXT,
|
281 |
-
ids_value
|
282 |
FOREIGN KEY(name) REFERENCES table_names(doc_name)
|
283 |
)
|
284 |
''')
|
|
|
182 |
|
183 |
return array
|
184 |
|
185 |
+
def int_to_bytes(value):
|
186 |
+
return value.to_bytes((value.bit_length() + 7) // 8, byteorder='big', signed=True)
|
187 |
+
|
188 |
+
def bytes_to_int(value):
|
189 |
+
return int.from_bytes(value, byteorder='big', signed=True)
|
190 |
+
|
191 |
def insert_data(conn, cursor, name, ids_array):
|
192 |
cursor.execute('INSERT INTO table_names (doc_name) VALUES (?)', (name,))
|
193 |
for ids in ids_array:
|
194 |
+
cursor.execute('INSERT INTO table_ids (name, ids_value) VALUES (?, ?)', (name, int_to_bytes(ids)))
|
195 |
conn.commit()
|
196 |
|
197 |
@st.cache_resource(show_spinner=False)
|
|
|
284 |
cursor.execute('''
|
285 |
CREATE TABLE table_ids (
|
286 |
name TEXT,
|
287 |
+
ids_value BLOB,
|
288 |
FOREIGN KEY(name) REFERENCES table_names(doc_name)
|
289 |
)
|
290 |
''')
|