Select 大写 table 名称在 postgreSQL 上不起作用

Select uppercase table name on postgreSQL is not working

我在 windows7 和 python3.4.4.

上使用 psycopg2

我想从大写名称的表中获取数据,但我无法弄清楚。谁能帮帮我?

总是这样返回 relation "table" does not exist 我想把 "table" 变成大写。

这是我的代码 导入 psycopg2

class KindOfCoupons:

   def get_coupons(self, cur, names):
       coupons = {}
       for name in names:
           coupons[name] = cur.execute("SELECT * FROM \"" + name + "\" ;")
       return coupons

   def connect_redshift(self):
       conn = psycopg2.connect("dbname=dbname host=host user=user password=password port=000")
       return conn.cursor()

   def get_coupon_used_type(self):
       cur = self.connect_redshift()
       names = ["TABLE", "TABLE_B", "TABLE_C"]
       coupons = self.get_coupons(cur, names)
       coupons[names[0]][0]

PostgresQL 列和 table 名称不区分大小写,除非 用引号将它们括起来(就像 "SELECT * FROM \"" + name + "\" ;" 一样)。

看到这个答案: