-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use damn ugly workarounds, do not use in production! #275
- Loading branch information
Showing
3 changed files
with
110 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import os | ||
from datetime import datetime | ||
from sqlalchemy.orm import sessionmaker | ||
import json | ||
|
||
from ding0.tools import results | ||
from ding0.io.export import export_network | ||
from egoio.tools.db import connection | ||
from ding0.io.db_export import create_ding0_sql_tables, export_all_dataframes_to_db | ||
|
||
|
||
if __name__ == '__main__': | ||
base_path = '/home/jonathan/RLI/rli-daten/Ding0/20180823154014/' | ||
schema = 'dingo' | ||
run_id = 'eGo_Abschluss_WS_v1' | ||
|
||
# mv_grid_districts = [2304, 2305, 2306, 2311, 2317, 2318, | ||
# 2319, 2320, 2321, 2322, 2375, 2376, | ||
# 2399, 2434, 2483, 2487, 2492, 2745, | ||
# 2749, 2775, 2776, 2783, 2813, 2827, | ||
# 2828, 2832, 2833, 2843] | ||
# mv_grid_districts.extend([739, 793, 1293, 1295, 1310, 1315, | ||
# 1316, 1317, 1318, 1325, 1328, 1329, | ||
# 1330, 1331, 1334, 1335, 1336, 2255, | ||
# 2275]) | ||
# mv_grid_districts.extend([746, 784, 831, 841, 842, 935, | ||
# 936, 942, 943, 948]) | ||
# mv_grid_districts.extend([1808, 1811, 1812, 1813, 1814, 1822, | ||
# 1823, 1824, 1831, 1943, 1947]) | ||
# mv_grid_districts.extend([9]) | ||
|
||
# mv_grid_districts = [1686, 1691, 1710, 1769, 1800, 2750, | ||
# 2751, 2757, 2785, 2809, 2820, 2852, | ||
# 2888, 2896, 2910] | ||
#mv_grid_districts = [1676, 1698, 1699, 1704, 1787, 1798] | ||
#mv_grid_districts = list(range(401,501)) | ||
# mv_grid_districts = [447, 299, 396, 374, 1699, 409, | ||
# 160, 1808, 11, 340, 306, 1329, | ||
# 2375, 2275, 189, 266, 396, 245, | ||
# 351, 238, 391, 474, 460] | ||
mv_grid_districts = [2079] | ||
|
||
filenames = ["ding0_grids__{ext}.pkl".format(ext=_) | ||
for _ in mv_grid_districts] | ||
|
||
|
||
# load Ding0 data | ||
nds = [] | ||
for filename in filenames: | ||
try: | ||
nd_load = results.load_nd_from_pickle(filename= | ||
os.path.join(base_path, | ||
filename)) | ||
|
||
nds.append(nd_load) | ||
except: | ||
print("File {mvgd} not found. It was maybe excluded by Ding0 or " | ||
"just forgotten to generate by you...".format(mvgd=filename)) | ||
|
||
nd = nds[0] | ||
|
||
for n in nds[1:]: | ||
nd.add_mv_grid_district(n._mv_grid_districts[0]) | ||
|
||
|
||
# #########SQLAlchemy and DB table################ | ||
db_engine = connection(section='local') | ||
session = sessionmaker(bind=db_engine)() | ||
|
||
# #########Ding0 Network and NW Metadata################ | ||
|
||
|
||
##################################################### | ||
|
||
# tested with reiners_db and oedb | ||
create_ding0_sql_tables(db_engine, ding0_schema=schema) | ||
# drop_ding0_db_tables(oedb_engine, SCHEMA) | ||
# db_tables_change_owner(oedb_engine, SCHEMA) | ||
|
||
# parameter: export_network_to_db(engine, schema, df, tabletype, srid=None) | ||
# export_network_to_db(reiners_engine, SCHEMA, lv_gen, "lv_gen", metadata_json) | ||
# export_network_to_db(CONNECTION, SCHEMA, mv_stations, "mv_stations", metadata_json) | ||
export_all_dataframes_to_db(db_engine, schema, nw=nd, my_run_id=run_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters