mysql-python

Python MySQLdb Programming Error: 1064 when inserting data

不羁岁月 提交于 2019-12-12 16:25:39
问题 I have this list info=[[u' Rasta.eon 2 - 1 Rasta.Xd ', u'Razer CS:GO Tournament 2', u'26-02-2014'], [u' XPC 1 - 2 WP.GG ', u'Roccat DotA 2 Tournament', u'26-02-2014']] conn= MySQLdb.connect(host='localhost',user='root',passwd='',db='ee') c = conn.cursor() query = "INSERT INTO todaysmatches (match,tournamentname,matchdate) VALUES (%s,%s,%s)" c.executemany(query, info) conn.commit() conn.close() when I try to execute the query I get this error ProgrammingError: (1064, "You have an error in your

MySQL in Python: UnicodeEncodeError: 'ascii'

喜欢而已 提交于 2019-12-12 12:23:44
问题 Hello I am trying to store a string value to MySQL, and i use db.escape_string() so not to escape special characters. The string is Lala*=#&%@<>_?!:;-'"/()¥¡¿ But when I try to run the code, I get this error: UnicodeEncodeError: 'ascii' codec can't encode characters in position 23-25: ordinal not in range(128) What should I do? 回答1: Try http://pypi.python.org/pypi/Unidecode/0.04.1 For example: from unidecode import unidecode your_string = 'Lala*=#&%@<>_?!:;-\'"/()¥¡¿' unidecode(your_string)

mysql.connector bug during “except” when compiled with pyinstaller?

廉价感情. 提交于 2019-12-12 11:44:36
问题 I have a python program which makes mysql calls that I build into an exe using pyinstaller. The following problem occurs with either a --onefile or a --onedir compile using pyinstaller. I have been able to use either mysqldb or mysql.connector to successfully connect and make queries. Here is the mysqldb connect logic: # from http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python try: db = MySQLdb.connect(host=hostname,user=username,passwd=password) except MySQLdb.Error as e: reply = QtGui

How to retrieve table names in a mysql database with Python and MySQLdb?

╄→尐↘猪︶ㄣ 提交于 2019-12-12 08:19:55
问题 I have an SQL database and am wondering what command you use to just get a list of the table names within that database. 回答1: SHOW tables 15 chars 回答2: To be a bit more complete: import MySQLdb connection = MySQLdb.connect( host = 'localhost', user = 'myself', passwd = 'mysecret') # create the connection cursor = connection.cursor() # get the cursor cursor.execute("USE mydatabase") # select the database cursor.execute("SHOW TABLES") # execute 'SHOW TABLES' (but data is not returned) now there

Python 3.7, Failed building wheel for MySql-Python

笑着哭i 提交于 2019-12-12 07:49:21
问题 I am new to python and I am trying django framework that involves some MySql and ran into this error when try to do pip install mysqlclient and down the lines of cmd messages I got this. Failed building wheel for mysqlclient Running setup.py clean for mysqlclient Failed to build mysqlclient Installing collected packages: mysqlclient Running setup.py install for mysqlclient ... error Complete output from command c:\users\ronanl~1\envs\py1\scripts\python.exe -u -c "import setuptools, tokenize;_

/usr/bin/ld: cannot find -lpython2.7

自作多情 提交于 2019-12-12 07:11:20
问题 I'm trying to install MySQLdb with Python 2.7. The error I'm getting looks like this: gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/opt/python2.7/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 gcc -pthread -shared build/temp.linux-x86_64-2.7/_mysql.o

bypass known exception of mysql in python

风流意气都作罢 提交于 2019-12-12 04:22:53
问题 I am trying to bypass " Cannot delete or update a parent row: a foreign key constraint fails " inside my python script. So I am planning to drop all tables but this error throws up due to inter relationship. My query is I need to get this automated and i know I am gonna come with the same error, but I know how to bypass it by calling SET FOREIGN_KEY_CHECKS=0; and then once deleted enable the feature again SET FOREIGN_KEY_CHECKS=1; . Need to know how to automate this inside python import

MySQL-Python & Django 1.5.0: no module named mysql.base error

允我心安 提交于 2019-12-12 02:19:46
问题 I am trying to create database table with Django by python manage.py syncdb and get an error Error was: No module named mysql.base . I know there are many questions like this on the web but none one of them helped me. Python version: 2.7.3 (default, Aug 1 2012, 05:16:07) \n[GCC 4.6.3] . Django version: (1, 5, 0, 'final', 0) . MySQL-Python version: MySQL_python-1.2.4b4-py2.7-linux-i686 . System information: Linux Marlon 3.5.0-26-generic #42~precise1-Ubuntu SMP Mon Mar 11 22:19:42 UTC 2013 i686

How can i validate in python if a username and password already exist in mySQL Database?

天大地大妈咪最大 提交于 2019-12-11 19:04:23
问题 Hi so I've been working on this project about a day now(New to python and mySQL) So my question is how i can see if the input user credentials in the textbox is already a registered user? So far I've managed to connect it to the database and store some values inside the database but i cant seem to figure out how i can scan that database and see if the user info are valid when the login button is pressed. from tkinter import* from tkinter import messagebox import mysql.connector import time

Plotting data of a mysql database by date

為{幸葍}努か 提交于 2019-12-11 14:22:57
问题 I created a mysql-database to save the humidity, temperature and several other datas with a timestamp. I can plot the data, but the x-axis is not labeled. I tried to set the label of the ticks, which did not labeled them correctly. It was not possible to see on which date which data was saved. The type of the dates is datetime.datetime() result = cursor.fetchall() for r in result: dates.append(r[1]) humidity.append(r[2]) temperature.append(r[3]) pm25.append(r[4]) pm10.append(r[5]) fig, ax =