54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
import sys
|
|
import os
|
|
from datetime import date
|
|
|
|
# Add project root to path
|
|
sys.path.append(os.path.abspath("d:/py_train/handover"))
|
|
|
|
from database.common_db_manager import CommonDatabaseManager
|
|
|
|
def insert_train_formations():
|
|
db = CommonDatabaseManager()
|
|
|
|
formations = [
|
|
# 101B~105B, 노포배속, 현대로템1단계
|
|
*[{"train_number": f"{i}B", "depot": "노포", "manufacturer": "현대로템1단계",
|
|
"total_cars": 40, "introduction_date": "2018-01-01", "is_new_train": 0}
|
|
for i in range(101, 106)],
|
|
|
|
# 106B~111B, 노포배속, 현대로템2단계
|
|
*[{"train_number": f"{i}B", "depot": "노포", "manufacturer": "현대로템2단계",
|
|
"total_cars": 48, "introduction_date": "2021-01-01", "is_new_train": 0}
|
|
for i in range(106, 112)],
|
|
|
|
# 112B~145B, 노포배속, 우진3단계
|
|
*[{"train_number": f"{i}B", "depot": "노포", "manufacturer": "우진3단계",
|
|
"total_cars": 200, "introduction_date": "2023-01-01", "is_new_train": 1}
|
|
for i in range(112, 146)],
|
|
|
|
# 146A~151A, 신평배속, 다대
|
|
*[{"train_number": f"{i}A", "depot": "신평", "manufacturer": "다대",
|
|
"total_cars": 48, "introduction_date": "2015-01-01", "is_new_train": 0}
|
|
for i in range(146, 152)],
|
|
]
|
|
|
|
for formation in formations:
|
|
query = """
|
|
INSERT OR REPLACE INTO train_formations
|
|
(train_number, depot, manufacturer, introduction_date, is_new_train)
|
|
VALUES (?, ?, ?, ?, ?)
|
|
"""
|
|
db.execute(query, (
|
|
formation["train_number"],
|
|
formation["depot"],
|
|
formation["manufacturer"],
|
|
formation["introduction_date"],
|
|
formation["is_new_train"]
|
|
))
|
|
|
|
db.commit()
|
|
print(f"✅ {len(formations)}개의 편성 정보가 입력되었습니다.")
|
|
|
|
if __name__ == "__main__":
|
|
insert_train_formations()
|