File size: 711 Bytes
17755b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from sqlalchemy.orm import Session
from app.db import base  # noqa
from app.db.session import engine
from app.models.dictionary_entry import DictionaryEntry


def init_db() -> None:
    base.Base.metadata.create_all(bind=engine)

    # Optional: seed some initial entries
    with Session(bind=engine) as db:
        if db.query(DictionaryEntry).count() == 0:
            sample = DictionaryEntry(
                headword_zomi="Tlang",
                headword_english="mountain",
                part_of_speech="noun",
                definition="A large natural elevation of the earth's surface",
                translations="mountain,hill",
            )
            db.add(sample)
            db.commit()