Найти - Пользователи
Полная версия: запись переменной в mysql
Начало » Python для новичков » запись переменной в mysql
1
ss100s
Есть бд ‘mydb’, таблица ‘mydb’, столбец ‘mydb’ тип text.
Пробую записать переменную:
 import MySQLdb
znachenie = "12345"
MyDB=MySQLdb.connect(host='localhost', user='mydb', passwd='pass', db='mydb', charset='utf8')
cursor = MyDB.cursor()
cursor.execute(""" INSERT INTO mydb(mydb) VALUES (%s)""", (znachenie))
MyDB.commit()
MyDB.close()
Скрипт отрабатывает, но при попытке посмотреть результат выдает:
 SHOW COLUMNS FROM [mydb];
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[mydb]' at line 1
mysql> SELECT * FROM [mydb];
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[mydb]' at line 1
ZerG
при чем тут питон?
py.user.next
ss100s
 , (znachenie))
Это не кортеж.

 (znachenie,)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB