RE: Error when doing sql

From: "Gubba, Aruna" <AGubba(at)eprod(dot)com>
To: Cravan <savageapple850(at)gmail(dot)com>, Adarsh Jaiswal <adarshjaiswal1989(at)gmail(dot)com>
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: RE: Error when doing sql
Date: 2019-06-12 13:25:51
Message-ID: 4b9059508f8e4a44a376a46ec60d74b5@PDEX13MBX06CORP.eprod.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Cravan,
I am not new to SQL, but new to Postgres and python scripting. I suspect somewhere in your python script there is still a reference to “title” instead “Title”, and you might want to search for that. I have been working with PgAdmin, but not worked with psql or python yet.
Hope someone can help you troubleshoot the problem.

Thank you,

Aruna Gubba

From: Cravan <savageapple850(at)gmail(dot)com>
Sent: Wednesday, June 12, 2019 8:15 AM
To: Gubba, Aruna <AGubba(at)eprod(dot)com>; Adarsh Jaiswal <adarshjaiswal1989(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Error when doing sql

Hi Aruna,
I have done what you suggested, and got a similar error with a “hint” this time
###############################
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site
-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site
-packages/sqlalchemy/engine/default.py", line 550, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.UndefinedColumn: column "title" does not exist
LINE 1: ...ear", "Runtime", "imdbID", "imdbRating") VALUES ((title), (y...
^
HINT: Perhaps you meant to reference the column "movies.Title".

The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "import.py", line 22, in <module>
main()
File "import.py", line 18, in main
{"title": title, "year": year, "runtime": runtime, "imdbID": imdbID, "im
dbRating:": imdbRating }) # substitute values from CSV line into SQL command
, as per this dict
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site
-packages/sqlalchemy/engine/base.py", line 2166, in execute
return connection.execute(statement, *multiparams, **params)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site
-packages/sqlalchemy/engine/base.py", line 982, in execute
return self._execute_text(object_, multiparams, params)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site
-packages/sqlalchemy/engine/base.py", line 1155, in _execute_text
parameters,
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site
-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context
e, statement, parameters, cursor, context
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site
-packages/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site
-packages/sqlalchemy/util/compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site
-packages/sqlalchemy/util/compat.py", line 128, in reraise
raise value.with_traceback(tb)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site
-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site
-packages/sqlalchemy/engine/default.py", line 550, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedColumn) column "t
itle" does not exist
LINE 1: ...ear", "Runtime", "imdbID", "imdbRating") VALUES ((title), (y...
^
HINT: Perhaps you meant to reference the column "movies.Title".

[SQL: INSERT INTO movies("Title", "Year", "Runtime", "imdbID", "imdbRating")
VALUES ((title), (year), (runtime), (imdbID), (imdbRating))]
[parameters: {'title': 'Title', 'year': 'Year', 'runtime': 'Runtime', 'imdbI
D': 'imdbID', 'imdbRating:': 'imdbRating\n'}]
(Background on this error at: http://sqlalche.me/e/f405<https://urldefense.proofpoint.com/v2/url?u=http-3A__sqlalche.me_e_f405&d=DwQFaQ&c=6zpojTjipf-nAlEmob0p1NKp0XhcK4Iau5zCDf5n3i4&r=EkFBsvaPSUevZPDtQjAAAQ&m=Xot5TRIVh5uMGwffElggSVh_Py_WMSNmnH5Kwtqqoi4&s=GttWMHmYIaInZ_L-jMF-E90rruf2yg1lhBuOMuJ8rj4&e=>)
Thanks,
Cravan
From: "Gubba, Aruna" <AGubba(at)eprod(dot)com<mailto:AGubba(at)eprod(dot)com>>
Date: Wednesday, 12 June 2019 at 9:10 PM
To: cool kid <savageapple850(at)gmail(dot)com<mailto:savageapple850(at)gmail(dot)com>>, Adarsh Jaiswal <adarshjaiswal1989(at)gmail(dot)com<mailto:adarshjaiswal1989(at)gmail(dot)com>>
Cc: "pgsql-novice(at)postgresql(dot)org<mailto:pgsql-novice(at)postgresql(dot)org>" <pgsql-novice(at)postgresql(dot)org<mailto:pgsql-novice(at)postgresql(dot)org>>
Subject: RE: Error when doing sql

Cravan,
Postgres is case-sensitive, and the columns names in your insert statement should exactly match the table definition.
Your insert into statement should look like this, (surround the exact column name around double quotes)
Insert into movies(“Title”,”Year”, “Runtime”,”imdbID”, “imdbRating”)

Thank you,

Aruna Gubba

From: Cravan <savageapple850(at)gmail(dot)com<mailto:savageapple850(at)gmail(dot)com>>
Sent: Wednesday, June 12, 2019 8:07 AM
To: Adarsh Jaiswal <adarshjaiswal1989(at)gmail(dot)com<mailto:adarshjaiswal1989(at)gmail(dot)com>>
Cc: pgsql-novice(at)postgresql(dot)org<mailto:pgsql-novice(at)postgresql(dot)org>
Subject: Re: Error when doing sql

Hi, here is the table:[cid:image001(dot)png(at)01D520F6(dot)532A9180]

From: Adarsh Jaiswal <adarshjaiswal1989(at)gmail(dot)com<mailto:adarshjaiswal1989(at)gmail(dot)com>>
Date: Wednesday, 12 June 2019 at 8:36 PM
To: cool kid <savageapple850(at)gmail(dot)com<mailto:savageapple850(at)gmail(dot)com>>
Cc: "pgsql-novice(at)postgresql(dot)org<mailto:pgsql-novice(at)postgresql(dot)org>" <pgsql-novice(at)postgresql(dot)org<mailto:pgsql-novice(at)postgresql(dot)org>>
Subject: Re: Error when doing sql

\d+ tablename

________________________________

This message (including any attachments) is confidential and intended for a specific individual and purpose. If you are not the intended recipient, please notify the sender immediately and delete this message.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Cravan 2019-06-12 13:27:04 Re: Error when doing sql
Previous Message Cravan 2019-06-12 13:14:41 Re: Error when doing sql