Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added relational.db
Binary file not shown.
43 changes: 42 additions & 1 deletion relational.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@
]

class AnnotationProcessor(Processor):
import csv
import sqlite3
connection = sqlite3.connect("relational.db")
cursor = connection.cursor()
create_table = '''CREATE TABLE annotations(
id STRING PRIMARY KEY,
body STRING NOT NULL,
target STRING NOT NULL,
motivation STRING NOT NULL);
'''
cursor.execute(create_table)
with open("data/annotations.csv") as file:
contents = csv.reader(file)
insert_records = "INSERT INTO annotations (id, body, target, motivation) VALUES(?, ?, ?, ?)"
cursor.executemany(insert_records, contents)
select_all = "SELECT * FROM annotations"
rows = cursor.execute(select_all).fetchall()
for r in rows:
print(r)
connection.commit()
connection.close()

def uploadData():
"""it takes in input the path of a CSV file containing annotations and uploads them in the database.
Expand All @@ -19,13 +40,33 @@ def uploadData():


class MetadataProcessor(Processor):
import csv
import sqlite3
connection = sqlite3.connect("relational.db")
cursor = connection.cursor()
create_table = '''CREATE TABLE metadata(
id STRING PRIMARY KEY,
title STRING NOT NULL,
creator STRING NOT NULL);
'''
cursor.execute(create_table)
with open("data/metadata.csv") as file:
contents = csv.reader(file)
insert_records = "INSERT INTO metadata (id, title, creator) VALUES(?, ?, ?)"
cursor.executemany(insert_records, contents)
select_all = "SELECT * FROM metadata"
rows = cursor.execute(select_all).fetchall()
for r in rows:
print(r)
connection.commit()
connection.close()

def uploadData():
"""it takes in input the path of a CSV file containing metadata and uploads them in the database.
This method can be called everytime there is a need to upload annotations in the database."""
pass


class QueryProcessor(Processor):

def getEntityById():
Expand Down