Access database connection via python in DataSpell

Is it possible to use the existing database connection in DataSpell to query from a database in python? Obviously there are existing tools to create a new connection with a database, but I'm looking for a way to do that securely without having to repeatedly enter credentials when debugging and developing a data pipeline.

Alternatively, since DataSpell maintains its own keepass file and the login credentials for it, it would also be sufficient to keep said database passwords in that keepass. However, I'm not sure if there is a way to access the credentials for that keepass via python. If DataSpell could recognize jupyter or terminal password requests and automatically populate them somehow that would also be sufficient and probably more secure.

0
4 comments

As for the first part - it's impossible to access existing data source from code in Python.

1

I'm not sure if there is a way to access the credentials for that keepass via python

It's possible to do that using third-party python libraries, for example https://github.com/libkeepass/pykeepass

If DataSpell could recognize jupyter or terminal password requests and automatically populate them somehow that would also be sufficient and probably more secure.

DataSpell can save Jupyter passwords to keepass, if it's selected as your preferred password storage in **Preferences | Appearance & Behavior | System Settings | Passwords**. If you enable "Remember" checkbox when password is requested, the IDE should not ask it again.
-1

Maybe my language wasn't clear enough. I know that dataspell maintains a keepass file and it can remember the password for jupyter kernels if they are password protected. I'm using a keepass file already to store a database password. However, I can't access that database password without also providing the master password to the keepass file each time the python or jupyter process is restarted. Currently my jupyter notebook in DataSpell prompts for the master password with a text field. When I was using jupyter in a browser keepass was able to recognize the password prompt via a browser extension and input the password for me. If DataSpell is able to recognize password requests from a notebook or python process and autofill that password I don't know how to do it.

What I really need is an external service that can securely remember a password or keep a database connection open so that a python process can request access to the connection or the password required to open a connection without requiring user authentication every time the python process is rebooted. Because DataSpell can do both of those things I was hoping there was a way to request those services via python instead of through user input to DataSpell

0

It's possible to do that using third-party python libraries, for example https://github.com/libkeepass/pykeepass/Tellthebell.com

Thank you for sharing the link, I will try to figure it out for more.

0

Please sign in to leave a comment.