cleanup & prepare for 2nd db
This commit is contained in:
@@ -1,28 +1,32 @@
|
||||
import yaml
|
||||
from eveal.database import engine
|
||||
from eveal.database import sde_engine, sqlite_sde_file_name
|
||||
from sqlmodel import Session, SQLModel
|
||||
from eveal import models_sde
|
||||
|
||||
import os
|
||||
os.remove("eveal.db")
|
||||
SQLModel.metadata.create_all(engine)
|
||||
try:
|
||||
os.remove(sqlite_sde_file_name)
|
||||
except:
|
||||
pass
|
||||
SQLModel.metadata.create_all(sde_engine)
|
||||
|
||||
|
||||
print("Importing SDE data...")
|
||||
print("Importing icons...")
|
||||
with open("static_eve/sde/fsd/iconIDs.yaml", "r") as f:
|
||||
with open("static_eve/sde/fsd/iconIDs.yaml", "r", encoding="utf-8") as f:
|
||||
icons = yaml.safe_load(f)
|
||||
|
||||
with Session(engine) as db:
|
||||
with Session(sde_engine) as db:
|
||||
for id, icon in icons.items():
|
||||
db.add(models_sde.Icon(id=id, **icon))
|
||||
db.commit()
|
||||
|
||||
|
||||
print("Importing categories...")
|
||||
with open("static_eve/sde/fsd/categoryIDs.yaml", "r") as f:
|
||||
with open("static_eve/sde/fsd/categoryIDs.yaml", "r", encoding="utf-8") as f:
|
||||
categories = yaml.safe_load(f)
|
||||
|
||||
with Session(engine) as db:
|
||||
with Session(sde_engine) as db:
|
||||
for id, category in categories.items():
|
||||
db.add(models_sde.Category(id=id,
|
||||
icon_id=category['iconID'] if 'iconID' in category else None,
|
||||
@@ -32,10 +36,10 @@ with Session(engine) as db:
|
||||
|
||||
|
||||
print("Importing groups...")
|
||||
with open("static_eve/sde/fsd/groupIDs.yaml", "r") as f:
|
||||
with open("static_eve/sde/fsd/groupIDs.yaml", "r", encoding="utf-8") as f:
|
||||
groups = yaml.safe_load(f)
|
||||
|
||||
with Session(engine) as db:
|
||||
with Session(sde_engine) as db:
|
||||
for id, group in groups.items():
|
||||
db.add(models_sde.Group(id=id,
|
||||
anchorable=group['anchorable'],
|
||||
@@ -51,11 +55,10 @@ with Session(engine) as db:
|
||||
|
||||
|
||||
print("Importing marketgroups...")
|
||||
with open("static_eve/sde/fsd/marketGroups.yaml", "r") as f:
|
||||
with open("static_eve/sde/fsd/marketGroups.yaml", "r", encoding="utf-8") as f:
|
||||
marketgroups = yaml.safe_load(f)
|
||||
|
||||
|
||||
with Session(engine) as db:
|
||||
with Session(sde_engine) as db:
|
||||
for id, marketgroup in marketgroups.items():
|
||||
db.add(models_sde.MarketGroup(id=id,
|
||||
description=marketgroup['descriptionID']['en'] if 'descriptionID' in marketgroup else None,
|
||||
@@ -68,10 +71,10 @@ with Session(engine) as db:
|
||||
|
||||
|
||||
print("Importing types...")
|
||||
with open("static_eve/sde/fsd/typeIDs.yaml", "r") as f:
|
||||
with open("static_eve/sde/fsd/typeIDs.yaml", "r", encoding="utf-8") as f:
|
||||
types = yaml.safe_load(f)
|
||||
|
||||
with Session(engine) as db:
|
||||
with Session(sde_engine) as db:
|
||||
for id, type in types.items():
|
||||
try:
|
||||
db.add(models_sde.Type(id=id,
|
||||
@@ -92,10 +95,10 @@ with Session(engine) as db:
|
||||
|
||||
|
||||
print("Importing materials...")
|
||||
with open("static_eve/sde/fsd/typeMaterials.yaml", "r") as f:
|
||||
with open("static_eve/sde/fsd/typeMaterials.yaml", "r", encoding="utf-8") as f:
|
||||
materials = yaml.safe_load(f)
|
||||
|
||||
with Session(engine) as db:
|
||||
with Session(sde_engine) as db:
|
||||
for id, material in materials.items():
|
||||
for mat in material:
|
||||
db.add(models_sde.TypeMaterial(type_id=id,
|
||||
|
||||
Reference in New Issue
Block a user