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

tests.seed_db.create_table()   A

Complexity

Conditions 2

Size

Total Lines 6
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
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