<jupyter_start><jupyter_text>Import the csv files and upload to GCP PostgreSQL server  Connect to the database and queryLoad libraries<jupyter_code>import pandas as pd
import os
from dotenv import load_dotenv
from sqlalchemy import create_engine<jupyter_output><empty_output><jupyter_text>Create connection to database Try to write to postgresql<jupyter_code>load_dotenv("../.env")
DB_STRING = os.getenv('DB_STRING')

db = create_engine(DB_STRING)<jupyter_output><empty_output><jupyter_text>Read the file and upload it to the SQL server<jupyter_code>from tqdm.notebook import tqdm
path = "../data/raw/drive_stats_2019_Q4/"
filenames = os.listdir(path)
for file in tqdm(filenames):
    print(file)
    df = pd.read_csv(path+file)
    df.to_sql('2021', con=db, schema='public', index=False, if_exists='append')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10023866348448687, 'fraction_numerical': 0.010739856801909307, 'mean_word_length': 7.0673076923076925, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '527348', 'license': 'MIT', 'n_tokens_mistral': 302, 'n_tokens_neox': 292, 'n_words': 70, 'path': 'notebooks/temp/felix-write_to_sql.ipynb', 'repo_name': 'ratm1509/ds-projects-capstone', 'size': '838'}