python - Select uppercase table name on postgreSQL is not working -


this question has answer here:

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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -