不直接使用表名访问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()

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

相关内容

热门资讯

透视了解!wepoker透视脚... 透视了解!wepoker透视脚本(透视)都是存在有挂(详细辅助透牌教程)1、用户打开应用后不用登录就...
重大通报!aa poker辅助... 这是一款非常优秀的aa poker辅助 ia辅助检测软件,能够让你了解到aa poker辅助中牌率当...
查到实测辅助!hhpoker是... 您好,菠萝辅助器免费版的功能介绍这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】...
透视了解!wepoker有没有... 透视了解!wepoker有没有机器人(透视)果然存在有挂(详细辅助软件教程);1、系统规律教程、辅助...
透视ai代打!hhpoker免... 透视ai代打!hhpoker免费透视脚本(透视)一贯有挂(详细辅助规律教程)hhpoker免费透视脚...
重要通知!wepoker挂,h... 重要通知!wepoker挂,hh poker辅助有用吗,专业教程(有挂技巧);最新版2024是一款经...
透视线上!wepoker轻量版... 透视线上!wepoker轻量版辅助(透视)竟然真的有挂(详细辅助详细教程)1、任何ai辅助神器的玩家...
推荐十款!pokemmo辅助官... 推荐十款!pokemmo辅助官网,wepoker钻石怎么看底牌,力荐教程(有挂教程);建议优先通过w...
透视系统!We poker辅助... 透视系统!We poker辅助器下载(透视)原来是真的有挂(详细辅助德州论坛)1、透视辅助简单,软件...
记者发布!pokemmo脚本辅... 记者发布!pokemmo脚本辅助器下载,aapoker脚本怎么用,必赢方法(有挂教程);pokemm...