-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved some pickles to exfor_dictionary
- Loading branch information
1 parent
3786dc5
commit 520bd3f
Showing
10 changed files
with
155 additions
and
175 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
include src/tabulated/MTall.dat | ||
include src/tabulated/*.json | ||
include src/submodules/utilities/*.txt | ||
include src/exforparser/tabulated/MTall.dat | ||
include src/exforparsertabulated/*.json | ||
include src/exforparser/submodules/utilities/*.txt | ||
include src/exforparser/pickles/*.pickle |
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
import sqlalchemy as db | ||
from sqlalchemy import insert | ||
import pandas as pd | ||
|
||
|
||
# from sql.creation import exfor_bib, exfor_reactions, exfor_index, exfor_data | ||
from sql.models import Exfor_Bib, Exfor_Reactions, Exfor_Indexes, Exfor_Data | ||
from config import engine, session | ||
|
||
connection = engine.connect() | ||
metadata = db.MetaData() | ||
|
||
|
||
def insert_df_to_data(df): | ||
df2 = df.astype(object).where(pd.notnull(df), None) | ||
# for record in df2.to_dict(orient="records"): | ||
# query = db.insert(exfor_data).values(record) | ||
# ResultProxy = connection.execute(query) | ||
|
||
df2.to_sql( | ||
"exfor_data", | ||
connection, | ||
index=False, | ||
if_exists="append", | ||
) | ||
|
||
|
||
def insert_bib(dictlist): | ||
# connection.execute(exfor_bib.insert(), dictlist) | ||
|
||
data = Exfor_Bib(**dictlist) | ||
session.add(data) | ||
session.commit() | ||
|
||
|
||
|
||
def insert_reaction(dictlist): | ||
# connection.execute(exfor_reactions.insert(), dictlist) | ||
for dict in dictlist: | ||
data = Exfor_Reactions(**dict) | ||
session.add(data) | ||
session.commit() | ||
|
||
|
||
|
||
def insert_reaction_index(dictlist): | ||
# connection.execute(exfor_index.insert(), dictlist) | ||
for dict in dictlist: | ||
data = Exfor_Indexes(**dict) | ||
session.add(data) | ||
session.commit() | ||
|
||
|
||
def show(): | ||
results = connection.execute(db.select([exfor_data])).fetchall() | ||
df = pd.DataFrame(results) | ||
df.columns = results[0].keys() | ||
df.head(4) | ||
|
||
|
||
|
||
def drop_tables(): | ||
for tbl in reversed(metadata.sorted_tables): | ||
engine.execute(tbl.delete()) | ||
|
||
|
||
|
Oops, something went wrong.