sde_types_market & rework infra
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import yaml
|
||||
from eveal.database import sde_engine, sqlite_sde_file_name
|
||||
from eveal.database import engine, sqlite_file_name
|
||||
from sqlmodel import Session, SQLModel
|
||||
from eveal import models_sde
|
||||
|
||||
import os
|
||||
try:
|
||||
os.remove(sqlite_sde_file_name)
|
||||
os.remove(sqlite_file_name)
|
||||
except:
|
||||
pass
|
||||
SQLModel.metadata.create_all(sde_engine)
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
|
||||
print("Importing SDE data...")
|
||||
@@ -16,9 +16,9 @@ print("Importing icons...")
|
||||
with open("static_eve/sde/fsd/iconIDs.yaml", "r", encoding="utf-8") as f:
|
||||
icons = yaml.safe_load(f)
|
||||
|
||||
with Session(sde_engine) as db:
|
||||
with Session(engine) as db:
|
||||
for id, icon in icons.items():
|
||||
db.add(models_sde.Icon(id=id, **icon))
|
||||
db.add(models_sde.SDEIcon(id=id, **icon))
|
||||
db.commit()
|
||||
|
||||
|
||||
@@ -26,14 +26,14 @@ print("Importing categories...")
|
||||
with open("static_eve/sde/fsd/categoryIDs.yaml", "r", encoding="utf-8") as f:
|
||||
categories = yaml.safe_load(f)
|
||||
|
||||
with Session(sde_engine) as db:
|
||||
with Session(engine) as db:
|
||||
for id, category in categories.items():
|
||||
if category["published"] == False:
|
||||
continue
|
||||
db.add(models_sde.Category(id=id,
|
||||
icon_id=category['iconID'] if 'iconID' in category else None,
|
||||
name=category['name']['en'],
|
||||
published=category['published']))
|
||||
db.add(models_sde.SDECategory(id=id,
|
||||
icon_id=category['iconID'] if 'iconID' in category else None,
|
||||
name=category['name']['en'],
|
||||
published=category['published']))
|
||||
db.commit()
|
||||
|
||||
|
||||
@@ -41,20 +41,20 @@ print("Importing groups...")
|
||||
with open("static_eve/sde/fsd/groupIDs.yaml", "r", encoding="utf-8") as f:
|
||||
groups = yaml.safe_load(f)
|
||||
|
||||
with Session(sde_engine) as db:
|
||||
with Session(engine) as db:
|
||||
for id, group in groups.items():
|
||||
if group["published"] == False:
|
||||
continue
|
||||
db.add(models_sde.Group(id=id,
|
||||
anchorable=group['anchorable'],
|
||||
anchored=group['anchored'],
|
||||
category_id=group['categoryID'],
|
||||
fittableNonSingletion=group['fittableNonSingleton'],
|
||||
icon_id=group['iconID'] if 'iconID' in group else None,
|
||||
name=group['name']['en'],
|
||||
published=group['published'],
|
||||
useBasePrice=group['useBasePrice']
|
||||
))
|
||||
db.add(models_sde.SDEGroup(id=id,
|
||||
anchorable=group['anchorable'],
|
||||
anchored=group['anchored'],
|
||||
category_id=group['categoryID'],
|
||||
fittableNonSingletion=group['fittableNonSingleton'],
|
||||
icon_id=group['iconID'] if 'iconID' in group else None,
|
||||
name=group['name']['en'],
|
||||
published=group['published'],
|
||||
useBasePrice=group['useBasePrice']
|
||||
))
|
||||
db.commit()
|
||||
|
||||
|
||||
@@ -62,15 +62,15 @@ print("Importing marketgroups...")
|
||||
with open("static_eve/sde/fsd/marketGroups.yaml", "r", encoding="utf-8") as f:
|
||||
marketgroups = yaml.safe_load(f)
|
||||
|
||||
with Session(sde_engine) as db:
|
||||
with Session(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,
|
||||
hasTypes=marketgroup['hasTypes'],
|
||||
icon_id=marketgroup['iconID'] if 'iconID' in marketgroup else None,
|
||||
name=marketgroup['nameID']['en'],
|
||||
parent_marketgroup_id=marketgroup['parentGroupID'] if 'parentGroupID' in marketgroup else None,
|
||||
))
|
||||
db.add(models_sde.SDEMarketGroup(id=id,
|
||||
description=marketgroup['descriptionID']['en'] if 'descriptionID' in marketgroup else None,
|
||||
hasTypes=marketgroup['hasTypes'],
|
||||
icon_id=marketgroup['iconID'] if 'iconID' in marketgroup else None,
|
||||
name=marketgroup['nameID']['en'],
|
||||
parent_marketgroup_id=marketgroup['parentGroupID'] if 'parentGroupID' in marketgroup else None,
|
||||
))
|
||||
db.commit()
|
||||
|
||||
|
||||
@@ -78,21 +78,21 @@ print("Importing types...")
|
||||
with open("static_eve/sde/fsd/typeIDs.yaml", "r", encoding="utf-8") as f:
|
||||
types = yaml.safe_load(f)
|
||||
|
||||
with Session(sde_engine) as db:
|
||||
with Session(engine) as db:
|
||||
for id, type in types.items():
|
||||
if type["published"] == False:
|
||||
continue
|
||||
db.add(models_sde.Type(id=id,
|
||||
group_id=type['groupID'],
|
||||
marketgroup_id=type['marketGroupID'] if 'marketGroupID' in type else None,
|
||||
name=type['name']['en'],
|
||||
published=type['published'],
|
||||
basePrice=type['basePrice'] if 'basePrice' in type else None,
|
||||
description=type['description']['en'] if 'description' in type else None,
|
||||
icon_id=type['iconID'] if 'iconID' in type else None,
|
||||
portionSize=type['portionSize'],
|
||||
volume=type['volume'] if 'volume' in type else None,
|
||||
))
|
||||
db.add(models_sde.SDEType(id=id,
|
||||
group_id=type['groupID'],
|
||||
marketgroup_id=type['marketGroupID'] if 'marketGroupID' in type else None,
|
||||
name=type['name']['en'],
|
||||
published=type['published'],
|
||||
basePrice=type['basePrice'] if 'basePrice' in type else None,
|
||||
description=type['description']['en'] if 'description' in type else None,
|
||||
icon_id=type['iconID'] if 'iconID' in type else None,
|
||||
portionSize=type['portionSize'],
|
||||
volume=type['volume'] if 'volume' in type else None,
|
||||
))
|
||||
db.commit()
|
||||
|
||||
|
||||
@@ -100,13 +100,13 @@ print("Importing materials...")
|
||||
with open("static_eve/sde/fsd/typeMaterials.yaml", "r", encoding="utf-8") as f:
|
||||
materials = yaml.safe_load(f)
|
||||
|
||||
with Session(sde_engine) as db:
|
||||
with Session(engine) as db:
|
||||
for id, material in materials.items():
|
||||
for mat in material['materials']:
|
||||
db.add(models_sde.TypeMaterial(type_id=id,
|
||||
material_id=mat['materialTypeID'],
|
||||
quantity=mat['quantity']
|
||||
))
|
||||
db.add(models_sde.SDETypeMaterial(type_id=id,
|
||||
material_id=mat['materialTypeID'],
|
||||
quantity=mat['quantity']
|
||||
))
|
||||
db.commit()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user