python - Select uppercase table name on postgreSQL is not working -
this question has answer here:
- postgres case sensitivity 1 answer
i'm using psycopg2 on windows7 , python3.4.4.
i'd data tables of uppercase name, couldn't figure out. can me?
always retuturn relation "table" not exist
want make "table" uppercase.
here's code import psycopg2
class kindofcoupons: def get_coupons(self, cur, names): coupons = {} name in names: coupons[name] = cur.execute("select * \"" + 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]
postgressql column , table names case insensitive, unless surround them quotes (like do, "select * \"" + name + "\" ;"
).
see answer: https://stackoverflow.com/a/21798517/1453822
Comments
Post a Comment