def main(): conn = psycopg2.connect("dbname=geflight user=postgres password=sx7%8rBSgB3SPuytB535") cur = conn.cursor() temp_file = "C:\\Users\\Public\\Temp\\temp.csv" data_path = os.path.join(os.environ["DataPath"], "GEFlight", "Release 1", "InitialTrainingSet_rev1") for root, dirs, files in os.walk(data_path): if "atscc" in root: continue for file_name in files: if not file_name.endswith(".csv"): continue create_temp_file(root, file_name, temp_file) table_name = file_name[:-4] ingest_command = csv_to_postgres.make_postgres_ingest(temp_file, table_name) cur.execute(ingest_command) conn.commit()
def main(): conn = psycopg2.connect("dbname=geflight user=postgres password=Postgres1234") cur = conn.cursor() temp_file = "C:\\Users\\Public\\Temp\\temp.csv" data_path = os.path.join(os.environ["DataPath"], "GEFlight", "Release 2", "PublicLeaderboardTrainDays", "2012_12_05") for root, dirs, files in os.walk(data_path): if "atscc" in root: continue for file_name in files: if not file_name.endswith(".csv"): continue create_temp_file(root, file_name, temp_file) table_name = file_name[:-4] ingest_command = csv_to_postgres.make_postgres_ingest(temp_file, table_name) cur.execute(ingest_command) conn.commit()
def get_sql(data_path, table_name): csv_path = os.path.join(data_path, table_name + ".csv") schema = csv_to_postgres.make_postgres_schema(csv_path, table_name) ingest = csv_to_postgres.make_postgres_ingest(csv_path, table_name) return schema + "\n\n" + ingest