Skip to content

Commit

Permalink
Location is attached to sampling_event. ObservationWrapper has a cust…
Browse files Browse the repository at this point in the history
…om insert function. Closes #68, closes #79
  • Loading branch information
vluzko committed Aug 18, 2022
1 parent a06f7bb commit fe58471
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions aukpy/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,26 +421,19 @@ def df_processing(cls, df: pd.DataFrame) -> pd.DataFrame:

return df

# @classmethod
# def insert(
# cls,
# df: pd.DataFrame,
# db: sqlite3.Connection,
# cache: Optional[Dict[Any, int]] = None, ) -> Tuple[pd.DataFrame, Dict[Any, int]]:
# # Table specific preprocessing
# if cache is None:
# cache = {}
# # sub_frame = cls.df_processing(df.loc[:, list(cls.columns)])
# # max_id = max_id if max_id is not None else 0
# # TODO: Optimization: Sort and drop_duplicates is probably faster.
# # groups_to_idx = sub_frame.fillna("").groupby(list(cls.unique_columns)).groups
# # new_idx = {g: idx[0] for g, idx in groups_to_idx.items() if g not in cache}
# # new_values = [sub_frame.loc[idx].tolist() for idx in new_idx.values()]

# import pdb
# pdb.set_trace()
# # db.executemany(cls.insert_query, new_values)
# return df, cache
@classmethod
def insert(
cls,
df: pd.DataFrame,
db: sqlite3.Connection,
cache: Optional[Dict[Any, int]] = None,
) -> Tuple[pd.DataFrame, Dict[Any, int]]:
# Table specific preprocessing
if cache is None:
cache = {}
sub_frame = cls.df_processing(df.loc[:, list(cls.columns)])
sub_frame.to_sql("observation", con=db, if_exists="append", index=False)
return df, cache


WRAPPERS = (
Expand Down

0 comments on commit fe58471

Please sign in to comment.