I'm running a batch of postgres queries from a python script. Some queries are as follow:
create table xxx [...]
Usually I get the following error:
psycopg2.ProgrammingError: relation "xxx" already exists
I know that i can manually delete the xxx table, but i ask me if there are a way to avoid this error. Something like delete xxx table if exist.
Thanks
Yes, there's DROP TABLE IF EXISTS:
IF EXISTSDo not throw an error if the table does not exist. A notice is issued in this case.
This option is available since version 8.2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With