The database does not want to connect to the host

2

I'm trying to connect to my MySQL database, I do not want to recognize the localhost, it bounces in error:

from sqlalchemy import create_engine  
from sqlalchemy.orm import sessionmaker  


eng = create_engine("mysql+mysqldb:///host='localhost', user='root',   passwd='...',port='3307', database='Nomina_jul15',echo=True")  

connection = eng.connect()  

I get this error:

  

_mysql_exceptions.OperationalError) MySQL server on 'localhost' (10061) ")

With pymsql:

eng = create_engine("mysql+pymysql:///....   

I get this error:

([WinError 10061] No se puede establecer una conexión ya que el equipo de   destino denegó expresamente dicha conexión)")  

I am somewhat confused because with MySQL and SQL statements it works normally, I can make the changes and queries I need.

    
asked by Jsierra2017 13.08.2017 в 22:13
source

1 answer

2

I think the topic is your connection string:

eng = create_engine("mysql+mysqldb:///host='localhost', user='root',   passwd='...',port='3307', database='Nomina_jul15',echo=True")  

According to the documentation for MySQL-Python , it should be something like this:

mysql+mysqldb://<user>:<password>@<host>[:<port>]/<dbname>

Therefore, try to change code to:

eng = create_engine("mysql+mysqldb://root:[email protected]:3307/Nomina_jul15",echo=True)  
    
answered by 15.08.2017 / 20:57
source