123456789101112131415161718192021222324252627 |
- from sqlalchemy import create_engine
- from sqlalchemy.orm import sessionmaker
- from time_recoder.time_recoder_config import DB_PATH
- from time_recoder.time_recorder_database.db_models import BASE, Task
- DATABASE_NAME = "time_recorder_database.db"
- ENGINE = create_engine("sqlite+pysqlite:///" + DB_PATH + "/" + DATABASE_NAME, echo=False, future=True)
- Session = sessionmaker(bind=ENGINE)
- def main():
- BASE.metadata.create_all(ENGINE)
- create_root_task()
- def create_root_task():
- session = Session()
- root_task = Task(parent_task_id=-1, name='root')
- session.add(root_task)
- session.commit()
- session.close()
- if __name__ == "__main__":
- main()
|