我正试图从数据库中删除一张表。只要name_Table是结构化的
schema.table一切都很好。但是,我在public模式中确实有一个表。当我试图删除它时:
public.subname.table我得到的答案是:
cross-database references are not implemented: "public.subname.table"如何丢弃public.subname.table
print('Connecting to the PostgreSQL database...')
postgresConnection = psycopg2.connect(
host=XXXXXX,
port=YYYYYYYYY,
database="mydb",
user=os.environ['user'],
password=os.environ['pwd'])
cursor = postgresConnection.cursor()
dropTableStmt = "drop TABLE %s;"%name_Table;
# Create a table in PostgreSQL database
print(dropTableStmt)
cursor.execute(dropTableStmt)
postgresConnection.commit()
cursor.close();
print('Database cursor closed.')
postgresConnection.close()
print('Database connection closed.')发布于 2021-10-11 22:50:20
DROP TABLE public."subname.table"做你想做的事。
sql.Identifier("public", "subname.table")是您想要的psycopg2标识符。
https://stackoverflow.com/questions/69437993
复制相似问题