I have python script where i am connecting to PostgreSQL database and trying to load the data to the tables.
timer('start', 'Writing values to Postgres database...')
engine = sqlalchemy.create_engine("postgresql://postgres:*****@localhost:5432/postgres")
processed_revtable = 'processed_revenues' #table names
model_revtable = 'models' #table name
with engine.connect() as conn:
df_revsattr.to_sql(processed_revtable, conn, if_exists = 'replace', index = False) #dataframe
df_modrev.to_sql(model_revtable, conn, if_exists = 'replace', index = False) #dataframe
timer('stop')
My python script is getting executed with no errors but i am not able to see any data being added to the tables in PostgreSQL.
I was trying to check if maybe there could be issue in connection but even if try to check for exception it is showing as success , doesn't matter if i give wrong or correct password.
from sqlalchemy import create_engine
from sqlalchemy.exc import SQLAlchemyError
engine = create_engine(
"postgresql+psycopg2://postgres:*****@localhost:5432/postgres")
try:
engine.connect()
print("success")
except SQLAlchemyError as err:
print("error", err.__cause__) # this will give what kind of error
NOTE: I am running the script on a server and PostgreSQL is also installed there. Recently there were some changes in PostgreSQL config file for vulnerability reasons, but i doubt that could the reason behind this behavior.