question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't connect to to SQL database with sqlalchemy

See original GitHub issue

I created a Jupyter Lab environment using this Link:

https://mybinder.org/v2/gh/JulianWgs/candas/master?urlpath=lab/tree/

Then I’m trying to connect to a SQL database with sqlalchemy:

from sqlalchemy import create_engine

ip = ""
port = ""
database = ""
engine = create_engine(
    'mysql+mysqldb://{}:{}@{}:{}/{}'.format(
        input("User: "), 
        getpass.getpass("Password: "), 
        ip, 
        port, 
        database), 
    pool_recycle=3600)
connection = engine.connect()

This fails with:

OerationalError: (MySQLdb._exceptions.OperationalError) (2003, "Can't connect to MySQL server on 'XXX.XXX.XXX.XXX' (110)")
(Background on this error at: http://sqlalche.me/e/e3q8)

It works with Google Colab and of course locally.

pip list:

CLICK ME

Package            Version  
------------------ ---------
aenum              2.2.1    
alembic            1.1.0    
asn1crypto         0.24.0   
async-generator    1.10     
attrs              19.1.0   
backcall           0.1.0    
bitstruct          8.8.1    
bleach             3.1.0    
blinker            1.4      
CANdas             0.1.0    
cantools           32.20.1  
certifi            2019.9.11
certipy            0.1.3    
cffi               1.12.3   
chardet            3.0.4    
cryptography       2.7      
cycler             0.10.0   
decorator          4.4.0    
defusedxml         0.5.0    
diskcache          4.1.0    
entrypoints        0.3      
idna               2.8      
ipykernel          5.1.2    
ipython            7.8.0    
ipython-genutils   0.2.0    
ipywidgets         7.4.2    
jedi               0.15.1   
Jinja2             2.10.1   
jsonschema         3.0.2    
jupyter            1.0.0    
jupyter-client     5.3.1    
jupyter-console    6.0.0    
jupyter-core       4.4.0    
jupyterhub         1.0.0    
jupyterlab         0.35.4   
jupyterlab-server  0.2.0    
kiwisolver         1.1.0    
Mako               1.1.0    
MarkupSafe         1.1.1    
matplotlib         3.1.1    
mistune            0.8.4    
mysqlclient        1.4.4    
nbconvert          5.4.1    
nbformat           4.4.0    
notebook           5.7.8    
nteract-on-jupyter 2.1.3    
numpy              1.17.3   
oauthlib           3.0.1    
pamela             1.0.0    
pandas             0.25.2   
pandocfilters      1.4.2    
parso              0.5.1    
pexpect            4.7.0    
pickleshare        0.7.5    
pip                19.2.3   
prometheus-client  0.7.1    
prompt-toolkit     2.0.9    
ptyprocess         0.6.0    
pycparser          2.19     
pycurl             7.43.0.2 
Pygments           2.4.2    
PyJWT              1.7.1    
pyOpenSSL          19.0.0   
pyparsing          2.4.2    
pyrsistent         0.15.4   
PySocks            1.7.0    
python-can         3.3.2    
python-dateutil    2.8.0    
python-editor      1.0.4    
pytz               2019.3   
pyzmq              18.1.0   
qtconsole          4.5.5    
requests           2.22.0   
scipy              1.3.1    
Send2Trash         1.5.0    
setuptools         41.2.0   
six                1.12.0   
SQLAlchemy         1.3.8    
terminado          0.8.2    
testpath           0.4.2    
textparser         0.21.1   
tornado            6.0.3    
traitlets          4.3.2    
urllib3            1.25.3   
wcwidth            0.1.7    
webencodings       0.5.1    
wheel              0.33.6   
widgetsnbextension 3.4.2    
wrapt              1.11.2   

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
manicscommented, Oct 21, 2019

Is your MySQL server hosted outside mybinder.org? If so the port will be blocked: https://github.com/jupyterhub/mybinder.org-deploy/blob/e58089d579a1851d920e756119fec3f5a04b317a/mybinder/values.yaml#L30

0reactions
manicscommented, Sep 20, 2021

Hi 👋 This is an old issue so I’m closing it. If you have more questions please use the Jupyter community forum https://discourse.jupyter.org/.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to connect to SQL Server using SQLALchemy
I am using a Windows 10 machine trying to connect to an SQL Serve (SQL Developer 2017) using Python.
Read more >
Connecting to SQL Database using SQLAlchemy in Python
To connect to a SQL database using SQLAlchemy we will require the sqlalchemy library installed in our python environment.
Read more >
Connections / Engines — SQLAlchemy 1.4 Documentation
I'm on SQL Server - how do I turn those ROLLBACKs into COMMITs? ... statement on the connection, the server does not respond...
Read more >
SQLAlchemy won't connect correctly but pyodbc and pymssql ...
'mssql+pyodbc://:@CMPDSQL01:1433/CMP?driver=SQL+Server+Native+Client+10.0'. The connection and simple query through pyodbc uses the following:.
Read more >
Connecting Pandas to a Database with SQLAlchemy
If the target SQL table doesn't exist yet, passing these datatypes will ensure that each SQL column is created with the appropriate data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found