Re: Error when doing sql
Adarsh Jaiswal <[email protected]> Wed, 12 Jun 2019 18:05:56 +0530
| Newsgroups | gmane.comp.db.postgresql.novice |
|---|---|
| Message-ID | <CANQY-0YHdQ1svvdnSnEwpdZgneL+MEwRDJDFpFpOTu9VqYYCVA@mail.gmail.com> |
Hi, Would you check the table created in postgresql, may be using "\d+ tablename" and post the response here ? Thanks and Regards, Adarsh Jaiswal On Wed, Jun 12, 2019 at 5:43 PM Cravan <[email protected]> wrote: > Hi Adarsh, > > I am still getting the same error. > > ############################################## > > Traceback (most recent call last): > > File > "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-package > > s/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-package > > s/sqlalchemy/engine/default.py", line 550, in do_execute > > cursor.execute(statement, parameters) > > psycopg2.errors.UndefinedColumn: column "title" of relation "movies" does > not exist > > LINE 1: INSERT INTO movies("title", "year", "runtime", "imdbID", "im... > > ^ > > 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, > 'imdbRating > > ': 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-package > > s/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-package > > s/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-package > > s/sqlalchemy/engine/base.py", line 1155, in _execute_text > > parameters, > > File > "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-package > > s/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-package > > s/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-package > > s/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-package > > s/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-package > > s/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-package > > s/sqlalchemy/engine/default.py", line 550, in do_execute > > cursor.execute(statement, parameters) > > sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedColumn) column > "title" of > > relation "movies" does not exist > > LINE 1: INSERT INTO movies("title", "year", "runtime", "imdbID", "im... > > ^ > > > > [SQL: INSERT INTO movies("title", "year", "runtime", "imdbID", > "imdbRating") VALUES > > ((title), (year), (runtime), (imdbID), (imdbRating))] > > [parameters: {'title': 'Title', 'year': 'Year', 'runtime': 'Runtime', > 'imdbID': 'imd > > bID', 'imdbRating': 'imdbRating\n'}] > > (Background on this error at: http://sqlalche.me/e/f405) > > > > > > Cravan > > > > *From: *Adarsh Jaiswal <[email protected]> > *Date: *Wednesday, 12 June 2019 at 8:07 PM > *To: *cool kid <[email protected]>, "[email protected]" < > [email protected]> > *Subject: *Re: Error when doing sql > > > > Hello Cravan, > > > > I meant the insert statement in the .py file. > > > Thanks and Regards, > > Adarsh Jaiswal > > > > > > On Wed, Jun 12, 2019 at 5:23 PM Cravan <[email protected]> wrote: > > Hi Adarsh, > > Do you mean that I should do so in the .py file or the > .sql file? > > Thanks and Regards, > > Cravan > > > > *From: *cool kid <[email protected]> > *Date: *Wednesday, 12 June 2019 at 7:51 PM > *To: *Adarsh Jaiswal <[email protected]> > *Subject: *Re: Error when doing sql > > > > You mean in the py file? > > > > *From: *Adarsh Jaiswal <[email protected]> > *Date: *Wednesday, 12 June 2019 at 7:50 PM > *To: *cool kid <[email protected]> > *Cc: *"[email protected]" <[email protected]> > *Subject: *Re: Error when doing sql > > > > Hi, > > > > Try adding double quotes around the column names in the query. > > > Thanks and Regards, > > Adarsh Jaiswal > > > > > > On Wed, Jun 12, 2019 at 4:20 PM Cravan <[email protected]> wrote: > > Hi all, > > Thank you for your replies. Now, I'm getting a weird > error code when I try to store values from a csv into an sql table in a > movie review assignment.I have already edited my apostrophes and spacing > and looked up examples from google to try and resolve my error to no avail. > I also ensured that i defined DATABASE_URL properly. Please note that my > csv values are stored in lists in each cell. They are arranged in a single > column such as > > The Lego Movie;2014;100;tt1490017;7.8 > > Please refer to the files attached. Here is the error code I’m getting: > > > > ###################################### > > ```` > > Traceback (most recent call last): > > File > "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-package > > s/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-package > > s/sqlalchemy/engine/default.py", line 550, in do_execute > > cursor.execute(statement, parameters) > > psycopg2.errors.UndefinedColumn: column "title" of relation "movies" does > not exist > > LINE 1: INSERT INTO movies(title, year, runtime, imdbID, imdbRating)... > > ^ > > > > > > 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, > 'imdbRating > > ': 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-package > > s/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-package > > s/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-package > > s/sqlalchemy/engine/base.py", line 1155, in _execute_text > > parameters, > > File > "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-package > > s/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-package > > s/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-package > > s/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-package > > s/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-package > > s/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-package > > s/sqlalchemy/engine/default.py", line 550, in do_execute > > cursor.execute(statement, parameters) > > sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedColumn) column > "title" of > > relation "movies" does not exist > > LINE 1: INSERT INTO movies(title, year, runtime, imdbID, imdbRating)... > > ^ > > > > [SQL: INSERT INTO movies(title, year, runtime, imdbID, imdbRating) VALUES > ((title), > > (year), (runtime), (imdbID), (imdbRating))] > > [parameters: {'title': 'Title', 'year': 'Year', 'runtime': 'Runtime', > 'imdbID': 'imd > > bID', 'imdbRating': 'imdbRating\n'}] > > (Background on this error at: http://sqlalche.me/e/f405) > > ```` > >