Can't connect to mysql using sqlalchemy. Library not loaded error
<p>I am trying to run a simple test code to connect ti a mysql db using sql alchemy.
The code is as follows:</p>

<pre><code>from sqlalchemy import (create_engine, Table, Column, Integer, String, MetaData)
import settings
import sys
try:
    db = create_engine('mysql://daniel:dani@localhost/test')
    db.connect()
except:
    print('opps ', sys.exc_info()[1])
</code></pre>

<p>I get the following error:</p>

<pre><code>dlopen(//anaconda/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: //anaconda/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so
  Reason: image not found
[Finished in 1.4s]
</code></pre>

<p>But running on terminal:</p>

<pre><code>locate libssl.1.0.0.dylib
</code></pre>

<p>I get:</p>

<pre><code>/Applications/Dtella.app/Contents/Frameworks/libssl.1.0.0.dylib
/Applications/XAMPP/xamppfiles/lib/libssl.1.0.0.dylib
/Users/dpereira14/anaconda/envs/dato-env/lib/libssl.1.0.0.dylib
/Users/dpereira14/anaconda/lib/libssl.1.0.0.dylib
/Users/dpereira14/anaconda/pkgs/openssl-1.0.1k-1/lib/libssl.1.0.0.dylib
/anaconda/lib/libssl.1.0.0.dylib
/anaconda/pkgs/openssl-1.0.2g-0/lib/libssl.1.0.0.dylib
/opt/local/lib/libssl.1.0.0.dylib
/usr/local/Cellar/openssl/1.0.1j/lib/libssl.1.0.0.dylib
</code></pre>

<p>I have no clue how to fix this error.</p>

<p>Thanks!</p>

<p>You are using python , so you have add mysqldb with mysql. Try the below code.</p>

<pre><code>try:
    db = create_engine('mysql+mysqldb://daniel:dani@localhost/test')
    db.connect()
except:
    print('opps ', sys.exc_info()[1])
</code></pre>

python mysql sqlalchemy