Форум сайта python.su
Здравствуйте! Запихиваю такой запрос через phpmyadmin:
SELECT User, LEFT(Db, LOCATE('\\', Db) - 1) FROM db WHERE User != '' and Db LIKE '%\\\\%'
db = MySQLdb.connect(host=access.get('host', 'localhost'), user=mysql_login, passwd=mysql_pass, db=_db) cursor = db.cursor() sql ="SELECT User, LEFT(Db, LOCATE('\\', Db) - 1) FROM db WHERE User != '' and Db LIKE '%\\\\%'" cursor.execute(sql)
_mysql_exceptions.ProgrammingError: (1064, "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 '\\\\%'' at line 1")
LIKE '%\\\\%'
LEFT(Db, LOCATE('\\', Db) - 1)
Офлайн
Попробуйте так
... sql = r"SELECT User, LEFT(Db, LOCATE('\\', Db) - 1) FROM db WHERE User != '' and Db LIKE '%\\\\%'" ...
Офлайн
terabaytЗаработапо
Попробуйте так
Офлайн