Checking if a postgresql table exists under python (and probably Psycopg2)

前端 未结 8 2011
我在风中等你
我在风中等你 2020-12-08 18:24

How can I determine if a table exists using the Psycopg2 Python library? I want a true or false boolean.

8条回答
  •  伪装坚强ぢ
    2020-12-08 19:06

    select exists(select relname from pg_class 
    where relname = 'mytablename' and relkind='r');
    

提交回复
热议问题