-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
26 lines (16 loc) · 728 Bytes
/
database.py
File metadata and controls
26 lines (16 loc) · 728 Bytes
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
from datetime import datetime
import uuid
from sqlalchemy import Column, DateTime, String, Text, create_engine
from sqlalchemy.orm import declarative_base, sessionmaker
DATABASE_URL = "sqlite:///./analysis.db"
engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False})
SessionLocal = sessionmaker(bind=engine)
Base = declarative_base()
class Analysis(Base):
__tablename__ = "analyses"
id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4()))
file_name = Column(String, nullable=False)
query = Column(String, nullable=False)
analysis = Column(Text, nullable=False)
created_at = Column(DateTime, default=datetime.utcnow)
Base.metadata.create_all(bind=engine)