Skip to content Skip to sidebar Skip to footer

Trying To Create A Redshift Table Using Python And Psycopg2 But The Table Does Not Get Created With No Errors Reported

My codes return no error but I don't see a table in Redshift...if I put 'if table exist' and try to create a table I know exists it does nothing and returns no error. Take that ou

Solution 1:

My codes return no error but I don't see a table in Redshift...if I put "if table exist" and try to create a table I know exists it does nothing and returns no error. Take that out and it will return duplicatetable error which is odd.

There is no problem with code or redshift. Whatever is happening is exactly expected.

if I put "if table exist" and try to create a table I know exists it does nothing and returns no error

This is expected as per Redshift documentation. Nothing wrong with it. Below goes documentation excerpt for if not exist.

IF NOT EXISTS

Clause that indicates that if the specified table already exists, the command should make no changes and return a message that the table exists, rather than terminating with an error. Note that the existing table might be nothing like the one that would have been created; only the table name is used for comparison.

This clause is useful when scripting, so the script doesn’t fail if CREATE TABLE tries to create a table that already exists.

Take that out and it will return duplicatetable error which is odd.

Its expected, table already exist, hence duplicate table error.

I don't see a table in Redshift

This should be an issue that either the user you are using to view table is not having rights to view that table or looking into some-other database by mistake. To prove my point that table exist, try inserting some records in table using your program and try selecting those records, if it happens, then its proved that table exists and having the data. Other user that you might be using to see table may not have rights to view it.

I hope it helps.

Post a Comment for "Trying To Create A Redshift Table Using Python And Psycopg2 But The Table Does Not Get Created With No Errors Reported"