UndefinedTableError: relation "pg_temp.session_vars" does not exist
I can successfully connect to a PostgreSQL database and execute queries against a database to view the data the tables contain.
However, when I try to execute an UPDATE, I get the following error:
UndefinedTableError: relation "pg_temp.session_vars" does not exist
I am creating a connection to the database by doing the following: (nothing special)
conn = await asyncpg.connect(user='username',
password='password',
database='databasename',
host='localhost')
I was wondering what, if anything, you might be aware of that would resolve this issue. Might there be something additional I need to do when setting up the connection?
(I can connect to the database directly via the shell and issue UPDATE's without any problems.)
Please provide error traceback. Does your UPDATE involve a temporary table? What does the query actually look like?
No, the query does not, as near as I can tell, involve a temporary table...
Query
UPDATE the_table SET the_column = 'new value' WHERE another_column = '42';
Traceback
UndefinedTableError Traceback (most recent call last)
/var/folders/7r/z2yvzrzx7_lg2h81285rsplr0000gp/T/ipykernel_40019/3361298876.py in <module>
32 await conn.close()
33
---> 34 asyncio.get_event_loop().run_until_complete(main())
~/depot/vagrant/env_vagrant/lib/python3.10/site-packages/nest_asyncio.py in run_until_complete(self, future)
68 raise RuntimeError(
69 'Event loop stopped before Future completed.')
---> 70 return f.result()
71
72 def _run_once(self):
~/.pyenv/versions/3.10.0/lib/python3.10/asyncio/futures.py in result(self)
199 self.__log_traceback = False
200 if self._exception is not None:
--> 201 raise self._exception
202 return self._result
203
~/.pyenv/versions/3.10.0/lib/python3.10/asyncio/tasks.py in __step(***failed resolving arguments***)
232 result = coro.send(None)
233 else:
--> 234 result = coro.throw(exc)
235 except StopIteration as exc:
236 if self._must_cancel:
/var/folders/7r/z2yvzrzx7_lg2h81285rsplr0000gp/T/ipykernel_40019/3361298876.py in main()
24 print( query )
25
---> 26 result = await conn.execute(query)
27
28 print( result )
~/depot/vagrant/env_vagrant/lib/python3.10/site-packages/asyncpg/connection.py in execute(self, query, timeout, *args)
316
317 if not args:
--> 318 return await self._protocol.query(query, timeout)
319
320 _, status, _ = await self._execute(
~/depot/vagrant/env_vagrant/lib/python3.10/site-packages/asyncpg/protocol/protocol.pyx in query()
~/.pyenv/versions/3.10.0/lib/python3.10/asyncio/futures.py in __await__(self)
282 if not self.done():
283 self._asyncio_future_blocking = True
--> 284 yield self # This tells Task to wait for completion.
285 if not self.done():
286 raise RuntimeError("await wasn't used with future")
~/.pyenv/versions/3.10.0/lib/python3.10/asyncio/tasks.py in __wakeup(self, future)
302 def __wakeup(self, future):
303 try:
--> 304 future.result()
305 except BaseException as exc:
306 # This may also be a cancellation.
~/.pyenv/versions/3.10.0/lib/python3.10/asyncio/futures.py in result(self)
199 self.__log_traceback = False
200 if self._exception is not None:
--> 201 raise self._exception
202 return self._result
203
Well, asyncpg itself does not attempt to access any "session_vars" table, so this must be an application error.