Reputation: 1
I connected the db by psycopg2.But can't select the column,use "select *" is ok.
import psycopg2
db = psycopg2.connect(host='ip',port='port',user='user', password='pw',
database='basdw')
print("Opened database successfully")
cur = db.cursor()
query = "SELECT UVCOOKIE FROM bas_appcvevent LIMIT 10"
cur.execute(query)
data = cur.fetchall()
print(data)
db.close()
Traceback (most recent call last): line 24, in cur.execute(query) psycopg2.ProgrammingError:
column "uvcookie" does not exist LINE 1: SELECT UVCOOKIE FROM bas_appcvevent LIMIT 10
but uvcookie is exist in the table.If I use "select *",it's ok.
import psycopg2
db = psycopg2.connect(host='ip',port='port',user='user', password='pw',
database='basdw')
print("Opened database successfully")
cur = db.cursor()
query = "SELECT UVCOOKIE FROM bas_appcvevent LIMIT 10"
cur.execute(query)
data = cur.fetchall()
print(data)
db.close()
output:
[(121, 1494990395269, None, 0, None, 0, 'j1wb5963_6_6_34_CA5F6F05-5273-4107-A1A2-3F98DE7DCA88', .....]
Upvotes: 0
Views: 270
Reputation: 1196
can you show the output of \d bas_appcvevent
Postgresql makes no difference between uppercase and lowercase so even if you type:
SELECT UVCOOKIE FROM bas_appcvevent LIMIT 10;
postresql does:
SELECT uvcookie FROM bas_appcvevent LIMIT 10;
If the column name is actually in uppercase then use double quotes like this:
SELECT "UVCOOKIE" FROM bas_appcvevent LIMIT 10;
Upvotes: 0