-
Notifications
You must be signed in to change notification settings - Fork 86
Description
Hi,
I was trying to use pgcontents to store Jupyter notebook code in PostgreSQL.
I set up a blank PostgresSQL database like it said in instructions and specified it in my jupyter_notebook_config.py:
from pgcontents import PostgresContentsManager c = get_config() # noqa c.NotebookApp.contents_manager_class = PostgresContentsManager c.PostgresContentsManager.db_url = 'postgresql://postgres:[email protected]/pgcontents'
Then I brought up the notebook in EKS and tried to see if it would save my Jupyter notebook code.
I got an error like this:
$ kubectl logs jupyter-deployment-f4846c8db-b7t95 -n jupyter
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 1283, in _execute_context
self.dialect.do_execute(
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/default.py", line 590, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.UndefinedTable: relation "pgcontents.users" does not exist
LINE 1: INSERT INTO pgcontents.users (id) VALUES ('root')
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.8/dist-packages/jupyter_core/application.py", line 270, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/traitlets/config/application.py", line 663, in launch_instance
app.initialize(argv)
File "", line 2, in initialize
File "/usr/local/lib/python3.8/dist-packages/traitlets/config/application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/notebook/notebookapp.py", line 1766, in initialize
self.init_configurables()
File "/usr/local/lib/python3.8/dist-packages/notebook/notebookapp.py", line 1383, in init_configurables
self.contents_manager = self.contents_manager_class(
File "/usr/local/lib/python3.8/dist-packages/pgcontents/pgmanager.py", line 99, in init
super(PostgresContentsManager, self).init(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/pgcontents/managerbase.py", line 66, in init
self.ensure_user()
File "/usr/local/lib/python3.8/dist-packages/pgcontents/managerbase.py", line 70, in ensure_user
ensure_db_user(db, self.user_id)
File "/usr/local/lib/python3.8/dist-packages/pgcontents/query.py", line 89, in ensure_db_user
db.execute(
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 1020, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 1133, in _execute_clauseelement
ret = self._execute_context(
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 1323, in _execute_context
self.handle_dbapi_exception(
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 1517, in handle_dbapi_exception
util.raise(
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/util/compat.py", line 178, in raise
raise exception
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 1283, in _execute_context
self.dialect.do_execute(
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/default.py", line 590, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "pgcontents.users" does not exist
LINE 1: INSERT INTO pgcontents.users (id) VALUES ('root')
Do I need to create the users, directories, files tables beforehand?
I am confused because the directions say:
Prerequisites:
Write access to an empty PostgreSQL database.
Also I was trying to look at the code and see where you actually create the tables, and I couldn't find where you actually do a 'CREATE TABLE' command. @ssanderson Could you please give guidance on this?
Thanks!