-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create DB tables in advance? #75
Comments
Hi @nsshah1288, The tables used by pgcontents are created by the |
Thanks @ssanderson for the quick reply! Right now I have a Dockerfile like this:
When I try to run I can't connect to the PostgreSQL DB that I have setup in AWS. Step 10/12 : RUN pgcontents init --db-url postgresql://postgres:postgres@academic-datalake.cluster-cprl6nrsccmr.us-east-1.rds.amazonaws.com/pgcontents --no-prompt This error makes sense, but I have not yet figured out how to supply temporary credentials in my jupyter_notebook_2_config.py file yet. When I used s3contents I was able to specify access key, secret key, and session token, and then it connected to s3. Is there a way to do this using pgcontents? Something like below? #c.PostgresContentsManager.access_key_id="blah" I am guessing I should instead put |
@ssanderson do you have any suggestions? |
hey @nsshah1288 . You only need to run For specifying your database credentials, you can put those in the jupyter notebook config. There's an example of what that looks like here: https://github.com/quantopian/pgcontents/blob/master/examples/example_jupyter_notebook_config.py. |
Hi @ssanderson thanks for the reply. I ran I provided the real username and password obviously. I am able to log into the query editor in AWS for this Aurora PostgreSQL serverless DB with the credentials. However, when I run sh-4.2$ pgcontents init About to run schema migrations against supplied database URL. If you have It is HIGHLY recommended that you back up stored data before proceeding. Proceed? [y/N]: y (Background on this error at: http://sqlalche.me/e/e3q8) Do you know if pgcontents works with Aurora PostgreSQL Serverless? Thanks |
Hi @ssanderson Thanks! |
I'm having a similar issue as pl31 created (pl31/heroku-jupyter#38).
|
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!
The text was updated successfully, but these errors were encountered: