forked from csci-e-29/2020fa-final-project-kumar-anish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load.py
28 lines (20 loc) · 685 Bytes
/
load.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import csv
from final_project import models
from final_project.database import SessionLocal, engine
def main(args=None):
db = SessionLocal()
models.Base.metadata.create_all(bind=engine)
print("loading csv results to database - start...")
with open("data/query_result_file.csv", "r") as f:
csv_reader = csv.DictReader(f)
for row in csv_reader:
db_record = models.QueryResult(
QueryID=row["QueryID"],
MatchScore=row["MatchScore"],
)
db.add(db_record)
db.commit()
print("loading csv results to database - done...")
db.close()
if __name__ == "__main__":
main()