不直接使用表名访问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,hhpoker脚本-本来一直总是有辅助脚本(哔哩哔哩)1、让任何用户...
透视解谜!wepoker怎么买... 透视解谜!wepoker怎么买辅助,wepoker手机插件-总是存在有辅助教程(哔哩哔哩)1、不需要...
透视曝光!wepoker提高好... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在这款游戏中打...
透视总结!wepoker破解是... 透视总结!wepoker破解是真的还是假的,wepoker怎么增加运气-真是存在有辅助教程(哔哩哔哩...
透视揭幕!wepoker透视脚... 透视揭幕!wepoker透视脚本,wepoker免费脚本咨询-都是真的有辅助神器(哔哩哔哩)1、游戏...
透视专业!wepoker透视脚... 透视专业!wepoker透视脚本免费app,wepoker怎么挂底牌-一直一直总是有辅助插件(哔哩哔...
透视推荐!wpk透视辅助,wp... 透视推荐!wpk透视辅助,wpk安卓下载辅助-一贯有辅助插件(哔哩哔哩)1、用户打开应用后不用登录就...
透视有挂!购买的wpk辅助在哪... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很多玩家在这款游戏中打...
透视教你!wpk透视辅助方法,... 透视教你!wpk透视辅助方法,wpk插件-一贯是真的有辅助软件(哔哩哔哩)1、不需要AI权限,帮助你...
透视了解!aapoker怎么选... 透视了解!aapoker怎么选牌,aapoker透视脚本-原来一直都是有辅助app(哔哩哔哩)1、玩...