pyodbc and mySQL

后端 未结 6 1408
死守一世寂寞
死守一世寂寞 2021-01-05 17:30

I am unable to connect to mySQl db using pyodbc.

Here is a snippet of my script:

import pyodbc
import csv

cnxn = pyodbc.connect(\"DRIVER={MySQL ODBC         


        
6条回答
  •  难免孤独
    2021-01-05 17:46

    Is that your driver name right?

    You can check your driver name in Windows -> Control panel -> System and security -> Administrative tools -> ODBC Data Sources -> Driver tab then copy the river name to the first parameter

    like

    cnxn = pyodbc.connect("DRIVER={MySQL ODBC 5.3 ANSI Driver}; SERVER=localhost;DATABASE=books; UID=root; PASSWORD=password;")
    

    And my problem solved

    or you may not install the driver and the step is simple.

提交回复
热议问题