Skip to content

Commit

Permalink
Merge pull request #91 from ADORSYS-GIS/34-implement-data-storage-fun…
Browse files Browse the repository at this point in the history
…ctionality

34 implement data storage functionality
  • Loading branch information
AssahBismarkabah authored Nov 28, 2023
2 parents 20d085a + 0a019e2 commit b2d91b0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# creating the database schema > database.py
import sqlite3

def create_database_schema():
Expand All @@ -17,4 +16,18 @@ def create_database_schema():
''')

connection.commit()
connection.close()
def store_analysis_results_in_database(results):
connection = sqlite3.connect('analysis_results.db')
cursor = connection.cursor()

try:
for result in results:
cursor.execute('''
INSERT INTO analysis_results (url, number_of_text, total_text, number_of_images)
VALUES (?, ?, ?, ?)
''', (result['url'], len(result['text']), len(result['total_text']), len(result['images'])))
except sqlite3.Error as e:
print(f"SQLite error: {e}")
finally:
connection.commit()
connection.close()

0 comments on commit b2d91b0

Please sign in to comment.