BP2024/annotation_app/initial.py
2024-04-11 17:31:10 +02:00

26 lines
601 B
Python

from models import db, Samples
from app import app
import json
import os
if __name__ == '__main__':
with app.app_context():
# db.init_app(app)
# creating database
db.create_all()
try:
with open(os.path.join('dataset', 'final_id_v2.jsonl'), encoding='utf-8') as file:
for line in file:
data = json.loads(line)
db.session.add(Samples(data['text']))
db.session.commit()
print('Data sucessfully inserted')
except FileNotFoundError as err:
print(err)