File size: 687 Bytes
deeb85c
 
 
 
2004aa8
deeb85c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from sqlalchemy import Column, Integer, String, Float, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

#DATABASE_URL = "sqlite:///:memory:?check_same_thread=False" # Use this for in-memory database
DATABASE_URL = "sqlite:///./database.db"

Base = declarative_base()

class Cable(Base):
    __tablename__ = "cables"
    id = Column(Integer, primary_key=True, index=True)
    type = Column(String, unique=True, index=True)
    resistance = Column(Float)

engine = create_engine(DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

def init_db():
    Base.metadata.create_all(bind=engine)