Skip to content
Advertisement

psycopg2: cursor.execute storing only table structure, no data

I am trying to store some tables I create in my code in an RDS instance using psycopg2. The script runs without issue and I can see the table being stored correctly in the DB. However, if I try to retrieve the query, I only see the columns, but no data:

This script runs without issues and, printing out file_check from the following script:

I get:

which looks good.

Running the following however:

returns:

Anybody have any idea why this is happening? I cannot seem to get around this

Advertisement

Answer

I was able to solve this: As it was pointed out by @AKX, I was only creating the table structure, but I was not filling in the table.

I now import import psycopg2.extras as well and, after this:

I add something like:

My table is now correctly filled after checking with pd.read_sql

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement