From 9e48f67e57657d648904b22b1f4e4d1c06f31693 Mon Sep 17 00:00:00 2001 From: Joe Steele Date: Wed, 19 Jun 2024 22:47:02 -0400 Subject: [PATCH] merged codbase and wrote some new database writing --- social.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/social.py b/social.py index 7aa13a4..6925045 100644 --- a/social.py +++ b/social.py @@ -29,6 +29,7 @@ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import null import googlemaps import env +import inspect Base = declarative_base() ################################################################################################## @@ -660,15 +661,18 @@ def write_to_database(data, local_outputs): Returns: Data: The data that was written to the database. """ - + column_list=[] print('write to database ...') + for x in inspect.getmembers(Posts): + if not (x[0].startswith('_') or 'metadata' in x[0]): + column_list.append(x[0]) cols = ["name", "comment", 'rating','picsURL','picsLocalpath','source','date','address', 'dictPostComplete'] cols2 = ["num","name", "comment", 'rating','picsURL','picsLocalpath','source','date', 'address','dictPostComplete'] #df = pd.DataFrame(local_outputs["xls"], columns=cols) - df = pd.DataFrame(local_outputs['xlsdf']) -# df = pd.DataFrame(local_outputs['xlsdf'].values, columns=cols2) +# df = pd.DataFrame(local_outputs['xlsdf']) + df = pd.DataFrame(local_outputs['xlsdf'].values, columns=column_list) df2 = pd.DataFrame(local_outputs['posts']) # print ('Dropped items not included in sync to database: ',df2.dropna(inplace=True)) # rows = list(data)