不直接使用表名访问PostgreSQL表。
创始人
2025-01-12 12:00:18
0

可以使用PostgreSQL元数据系统中的信息来访问表,例如查询sys.tables视图获取表的信息,然后使用该信息来访问表。以下是一个使用Python语言的示例代码:

import psycopg2

# Connect to the PostgreSQL database
conn = psycopg2.connect(database="mydb", user="myuser", password="mypassword", host="localhost", port="5432")
cur = conn.cursor()

# Get information about the table
cur.execute("SELECT * FROM sys.tables WHERE table_name = 'mytable'")
table_info = cur.fetchone()

# Use the information to access the table
table_name = table_info[0] # Assuming the table name is in the first column
cur.execute("SELECT * FROM " + table_name)

# Use the table data
for row in cur.fetchall():
    print(row)

# Close the database connection
conn.close()

请注意,这只是一个示例,实际上访问表时应该更复杂和安全。

相关内容

热门资讯

透视最新!hhpoker辅助软... 透视最新!hhpoker辅助软件下载,wpk透视辅助靠谱吗,秘笈分析(有挂教程)1、快速入门:当你通...
透视线上!德普之星透视辅助,大... 德普之星透视辅助赢率提升策略‌;透视线上!德普之星透视辅助,大菠萝免费辅助,新版2025教程(真是真...
透视辅助!hhpoker透视下... 透视辅助!hhpoker透视下载链接在哪里,wpk有脚本吗,1分钟了解(有挂总结)1、在hhpoke...
辅助透视!智星菠萝辅助,wep... 智星菠萝辅助新手教程相关信息汇总(需添加指定Q群1067239143获取下载链接);辅助透视!智星菠...
透视私人局!aapoker免费... 透视私人局!aapoker免费透视脚本,hhpoker免费透视脚本,发现一款(有挂教程)是一款可以让...
透视透视挂!hhpoker辅助... 透视透视挂!hhpoker辅助下载,wepokerplus开挂,2025版教程(原本存在有挂)1、许...
透视实锤!aapoker俱乐部... 透视实锤!aapoker俱乐部靠谱吗,aapoker透视插件下载,每日必备(有挂教学),亲,有的,a...
透视实锤!wpk透视表,hhp... 【福星临门,好运相随】;透视实锤!wpk透视表,hhpoker德州挂真的有吗,wpk教程(固有有挂)...
透视能赢!aapoker可以开... 透视能赢!aapoker可以开挂吗,hhpoker辅助软件,终于发现(有挂教程)是一款可以让一直输的...
透视了解!德普之星怎么作弊,w... 1、透视了解!德普之星怎么作弊,wepokerplus开挂,专业教程(切实真的是有挂)(UU pok...