Passed
Branch master (3d8412)
by satyam
01:18
created

tests.seed_db   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 2
1
from curses import echo
2
from sqlalchemy import (create_engine, Column, String, Integer, Index, engine)
3
from sqlalchemy.ext.declarative import declarative_base
4
5
Base = declarative_base()
6
7
8
class User(Base):
9
    __tablename__ = "user"
10
    username = Column("username", String(20), primary_key=True)
11
    age = Column("age", Integer)
12
    __table_args__ = (
13
        Index("idx_user_username", "username"),
14
    )
15
16
17
def create_table():
18
    e: engine.Engine = create_engine(
19
        "sqlite:///test.db", echo=True, future=True)
20
    with e.begin() as c:
21
        Base.metadata.create_all(bind=c)
22
    return e
23