SQL connection works in VBA but not in Python -


I have a code that reads from a SQL server whose parameters are set as follows.

  global console my_db = "driver = {SQL server}; server = my_server; initial catalog = my_catalog; uid = user; pwd = opensesame;" However, translating into Python does not work for me:  
  import _mysql db = _mysql.connect (host = "my_server", user  

me Received error

  traceback (most recent call final)  

: File ". \ Db_test.py", line 6, in the & Gt; Db = _mysql.connect (host = "my_server", user = "user", passwd = "opensesame", db = "my_db") file "C: \ python27 \ lib \ site-packages \ MySQLdb \ __ init__ .py ", line 81, the connect return return connection (* args, ** kwargs) in the file" C: \ python27 \ lib \ site-packages \ MySQLdb \ contacts.py ", line 187, __init__ in super The connection can not be connected to the MySQL server at the "MyServer" (10061)) .__ / init __ (* Args, ** kwargs2) _mysql_exceptions.OperationalError:)

< P> What am I doing wrong?

Your SQL Server MS SQL server connects to your VBA script port 1433 on SQL Server. Trying to connect to MySQL server on Python script port 3306 (the default port of MySQL).

Try it:

import pyodbc
cnxn = pyodbc.connect ('DRIVER = {SQL server}; server = my_server; initial catalog = my_catalog; uid = user; pwd = Opensem '


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -