0
0 комментариев

Написал код

__author__ = 'Ronald'
 
import mysql.connector
import pyodbc
 
DBfile=r'C:\Guitars.accdb'
cnx = mysql.connector.connect(user='root', password='',
                              host='localhost', port='3306',
                              database='guitars')
 
cnx1 = pyodbc.connect(r'Driver={Microsoft Access Driver (*.accdb)};DBQ=+DBfile')
 
cursor = cnx.cursor()
cursor1 = cnx1.cursos()
 
cmd = ''
while (cmd!='exit'):
n = int(raw_input('1-mysql, 2-MSAccess: '))
s = raw_input('sql query: ')
if (n==1):
cursor.execute(s)
if ('select' in s):
data=cursor.fetchall()
for row in data:
print row
else:
print 'executed!'
if (n==2):
        cursor1.execute(s)
        if('select' in s)or ('show'in s):
            data=cursor1.fetchall()
            for row in data:
                print row
        else:
            print'executed!'
 
    cmd=raw_input('print to close "exit":')
 
cnx1.close()
 
cnx.close()

В итоге выдает ошибку

File
«C:/Users/Ronald/PycharmProjects/untitled2/guitars.py»,
line 11, in
cnx1 = pyodbc.connect(r’Driver={Microsoft
Access Driver (*.accdb)};DBQ=+DBfile’)
pyodbc.Error: (‘IM002’, ‘[IM002]
[Microsoft][\xc4\xe8\xf1\xef\xe5\xf2\xf7\xe5\xf0
\xe4\xf0\xe0\xe9\xe2\xe5\xf0\xee\xe2
ODBC] \xc8\xf1\xf2\xee\xf7\xed\xe8\xea
\xe4\xe0\xed\xed\xfb\xf5 \xed\xe5
\xed\xe0\xe9\xe4\xe5\xed \xe8 \xed\xe5
\xf3\xea\xe0\xe7\xe0\xed
\xe4\xf0\xe0\xe9\xe2\xe5\xf0,
\xe8\xf1\xef\xee\xeb\xfc\xe7\xf3\xe5\xec\xfb\xe9
\xef\xee
\xf3\xec\xee\xeb\xf7\xe0\xed\xe8\xfe
(0) (SQLDriverConnect)’)

Process finished with exit code 1


Добавить комментарий