Use this tag for questions about the MySQL-Python database connector library (MySQLdb). Do not use this tag for questions about MySQL Connector/Python (use the [mysql-connector-python] tag instead).

learn more… | top users | synonyms (1)

0
votes
1answer
12 views

Python MySQLdb select fresh data from a infinite thread

Using python2.7 and MySQLdb I'd like to have an infinite thread that will perform a SELECT query from times to times. It seems that the only first SELECT is taken into consideration, when I'm modyfing ...
0
votes
1answer
20 views

Flask Python: MySQLdb, %s unable to access database (to prevent SQL injection)

I am referring this post https://ianhowson.com/blog/a-quick-guide-to-using-mysql-in-python/ that %s is prefer as it prevent SQL injection while '%s' is not. However, I try to convert a working code ...
2
votes
1answer
24 views

Python3+Django1.10+mysqlclient1.3.9: cannot save emoji characters

I got the error below in django when saving a field with emoji character in the admin panel. OperationalError at /admin/core/message/add/ (1366, "Incorrect string value: '\xF0\x9F\x98\x9E \xF0....
0
votes
0answers
9 views

Windows 10 + Python + Mariadb: `ImportError: this is MySQLdb version but _mysql is version

When trying to import module MySQLdb(Installed) on python 2.7 (Windows 10 64bit): I got this error: ImportError: this is MySQLdb version (1, 2, 3, 'final', 0), but _mysql is version (1, 2, 5, 'final',...
0
votes
2answers
14 views

Flask mySQLDB execute success or failure

I am new to Python-Flask and am trying to use MySQLDB to conenct to the database. However, I am unable to determine how to check if the query executed by the cursor is successful or if it failed. In ...
0
votes
0answers
14 views

SQLAlchemy Performance Issue

I wonder what could be a reason the execution of the same INSERT command takes 20 times longer when sqlalchemy engine is used. Here is the example. Connect to db: from sqlalchemy import ...
0
votes
0answers
13 views

How to create entities in MySQL linking them with Foreign Key

After connecting to MySQL db: import MySQLdb db = MySQLdb.connect(host="localhost", user="username", passwd="pass", db="test") I go ahead and create two tables: "Writers" and "Readers" with "...
0
votes
2answers
24 views

How to create Foreign Key using MySQLdb

After importing MySQLdb module I go ahead and connect to MySQl Maria db: import MySQLdb db = MySQLdb.connect(host="localhost", user="user", passwd="pass", db="test") Now I want to create two tables:...
0
votes
0answers
27 views

MySQL Server throws an error: ERROR 2002 (HY000) in CentOS

It's quite a weird issue that I have been facing for past few days and now finally figured out the reason. But, still searching for a solution for this issue. I have installed MySQL in my cloud ...
0
votes
1answer
28 views

from ConfigParser import SafeConfigParser ImportError: No module named 'ConfigParser'

I am getting below error: "from ConfigParser import SafeConfigParser ImportError: No module named 'ConfigParser'' I am trying to install Mysql-python in python3 but not getting success.
0
votes
1answer
32 views

Using App Engine Datastore over MySQL for a CRM System

I am about to take on a project, and I will to ask which database is best to use to build and develop a CRM System that does a lot of reporting and calculations for an Advertisement company. My ...
0
votes
0answers
19 views

Loop with insert queries break after 8th iteration

I have a script which one pare some data from web page and insert this data to two MySQL tables. But each time my loop broke after 8th loop. I mean script inser 8 new rows and script finished with ...
0
votes
1answer
24 views

Python, MySQL _mysql_exceptions.ProgrammingError: (1064, 'You have an error in your SQL syntax

Im currently sending a twitter stream to a local MySQL db and I have run into an issue. Whenever a user creates a tweet with " located within it, I will get a syntax error because it messes with the ...
-3
votes
0answers
38 views

SQL query works in mysql workbench but not in app

I have an application that makes a very simple select call to my database but it will not work. It says that I have a syntax error. However, when I test the query in mysql workbench and in the command ...
0
votes
1answer
92 views

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'

I have created a django project for which i used MySQL database. I have mysql-python connector in mysql installed tools. I am not sure whether i set a required path in environmental variables. When i ...
0
votes
1answer
39 views

_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax;)

I'm new usign MySLQdb for Python. I have this code: for row in csv_reader: insert = """INSERT INTO %s VALUES (DEFAULT, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) "...
0
votes
1answer
28 views

Validate login using javascript from a login page by clicking on “Login button”

Suppose I have a javascript for a "Log in" button in a login.html page. The javascript can look like this var attempt = 3; // Variable to count number of attempts. // Below function ...
0
votes
1answer
22 views

How to store data in a database to identify process started on the server

Could you enlighten me how to store data in a database to identify process started on the server? Code is below. I run it on Flask (python) with MySQL database on Cloud 9. To sump up, I do not want ...
0
votes
1answer
26 views

Connect to mysql with sqlalchemy and query

I have a MySQL database with stock market quotes. I'm trying to create a python script to connect to the database and query it. Here is my python script... from flask import Flask from ...
0
votes
0answers
14 views

Import Mysqldb Reason: image not found

I used Mysqldb for my python program, To install it I used : conda install -c CEFCA mysql-python=1.2.5, because conda install mysql-db doesn't work. However when I run my program I get error : ...
0
votes
1answer
29 views

Python import MySQLdb: Library not loaded: libmysqlclient.18.dylib

macOS Sierra 10.12.1 MySQL 5.7.16 MySQL-python 1.2.5 Python 2.7 ======================================= When i import MySQLdb it show errors as follow Traceback (most recent call ...
0
votes
1answer
35 views

Python: Can't run Python executable file created by cx_freeze (with text file)

I have written a Python program to take the backup of all objects of MySQL db individually. The program works fine when run on my machine, but when I use cx_freeze to create an executable file, it ...
0
votes
0answers
21 views

insert a point with Python MySQL

I have a table created by the following SQL instruction: CREATE TABLE venues (id CHAR(32) NOT NULL PRIMARY KEY, name VARCHAR(400), location POINT NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8; A ...
0
votes
0answers
14 views

MySQL and Qt4 Data not in table

The code in Pycharm : # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'read1.ui' # # Created: Mon Nov 28 19:43:19 2016 # by: PyQt4 UI code generator 4.10.4 # # ...
0
votes
0answers
34 views

Inserting timestamp using MySQLDB

I'm having trouble with this particular SQL insertion I'm performing using MySQLdb on Python. The particular schema for the table I'm attempting to insert into has been created with the following ...
1
vote
1answer
42 views

Flask_SQLAlchemy, MySQL, store Swedish characters å, ä, ö?

I can't sto re Swedish characters in MySQL by using Flask_SQLAlchemy :( I have tried to find a solution for a week now and I really need help as it feels like I have reached a dead end. I think it ...
2
votes
2answers
26 views

How to use python statement to check the sql table is exist or not.?

I would like to know how to write the python statement to check whether the sql table is exist or not. if the table is exist , then I will insert data to the table, otherwise, I will create the ...
2
votes
1answer
32 views

mysql delete rows with duplicate dates keeping the latest one

In my mysql database I have a table similar to this one: Data |Val | Val2 2016-11-11 14:48:38 |10 | 20 2016-11-11 14:48:38 |30 | 40 2016-11-06 11:48:38 |50 | 60 2016-11-08 19:...
0
votes
0answers
27 views

Convert Python MySQL query result to JSON [duplicate]

How can I return the result of a SQL query as JSON? If I was using PHP, I would do $query=DB::query("SELECT * from t_product")->execute()->as_array(); return json_encode($query); I will not be ...
1
vote
1answer
131 views

Error installing mysql-python: library not found for -lssl

I'm having trouble installing mysql-python. Created a new virtualenv and when installing mysql-python... here's the error message: (env)$ pip install mysql-python Collecting mysql-python ... clang -...
0
votes
1answer
16 views

Passing mySQL cursor as return type in a python function

I am connecting to mysql db from python using standard mysql.connector driver. I defined below function to create a cursor object in order to execute any db queries/DMLs import mysql.connector as ...
-1
votes
1answer
44 views

Python AWS Lambda spins new connection to RDS for each deployment

I have a python based Lambda function, that connects to MySQL(RDS) database. Every time I deploy the Lambda code and run the function, a new connection is created. How can I reuse the same ...
0
votes
1answer
56 views

How to install MySQL-python by pip?

venv/bin/pip install MySQL-python Collecting MySQL-python Downloading MySQL-python-1.2.5.zip (108kB) 100% |████████████████████████████████| 112kB 1.2MB/s Complete output from command python ...
0
votes
3answers
61 views

loop over all tables in mysql databases

I am new with MySQL and I need some help please. I am using MySQL connector to write scripts. I have database contain 7K tables and I am trying to select some values from some of these tables ...
-3
votes
1answer
24 views

Chat storage in MySQL [closed]

My friend and I run an IRC chat for a group of our friends, problem is that the history deletes when you log in, and doesn't store it anywhere, so when we try to reference something said earlier, the ...
0
votes
2answers
35 views

Python MySQLdb execute slow

I have a very long execution time (as opposed to long fetch times) using Python MySQLdb to fetch data from a big table, and I would like to understand if anything is obviously wrong. My table is ...
0
votes
0answers
27 views

Error while using MySql with Python 3.4.3 and Django 1.9.6

I have tried using pymysql mysql-client mysql-connector-pyhton and various other ways stated in this question but still I am not able to use MySql as my database. Whenever I try to do run it shows ...
2
votes
1answer
36 views

mysqlclient sporadically crashes making TLS connections

I'm using mysqlclient to connect from one server to another, which is running MariaDB 10.0.27. Connections that don't use TLS work without any problem. Most connections that do use TLS work without ...
0
votes
0answers
20 views

How to install python-dev without yum

When I install the Mysql-python-1.2.5,it failed that it cannot find the file Python.h,so I need to install the python-dev-2.6.6 package ,but my centos cannot connect to the Internet,so I need the tar....
0
votes
0answers
26 views

MySQL fails persistently after power removal (Raspberry Pi)

I have a small Python script that monitors a couple of GPIO pins and logs their states to an MySQL database. Every couple of minutes, it bundles all of these local observations up and POSTs them to a ...
0
votes
0answers
17 views

Python MySQLdb escape() unicode strings

I have a table in utf-8: show create table test returns: CREATE TABLE `test` ( ( ... ) ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8 | open connection and get cursor import MySQLdb ...
0
votes
1answer
17 views

MySQLdb execute() works with unicode but not with subclass of unicode

I am building a library that extends unicode class with some other methods, I discovered that MySQLdb is failing when using my unicode class. This works : In [23]: c.execute("""SELECT * FROM ...
0
votes
0answers
20 views

Why MySQL server needs client to send COM_STMT_RESET explicitly before each execution while using prepared statement?

MySQL official python connector, using prepared statement needs extra interactive which is sending Reset Prepared Statement Command, this operation takes one RTT between client and server, slowing ...
0
votes
1answer
28 views

Django: Raw SQL with connection.cursor()

I am a complete newbie to Django. I need to perform the following query and use img.img_loc to populate a list of images in a template: SELECT img.img_loc, author.surname, author.given_name, author....
1
vote
1answer
47 views

Importing CSV into Mysql Python 3.x

I'm trying to import a csv file into mysql using python for practice. I believe I've downloaded the right libraries. Every time I run my code I get the error: mysql.connector.errors.ProgrammingError:...
0
votes
0answers
18 views

Change isolation level in records query or close transaction

I'm trying to build some autotest scripts using Kenneth Reitz's records library. I need to check the MySQL database for updates here and there. db_url_mysql = 'mysql://user:[email protected]:3306/...
0
votes
2answers
114 views

MYSQL: “Access denied for user 'X'@'localhost' (using password: YES)” PYTHON

I'm trying to access the database using python but it's just not working. When I access a remote database everything is fine. But local there is some kind of problem. What I'm doing wroing here? I've ...
1
vote
2answers
17 views

mysqldb database storage in ram

I am new to Python. I am trying to implement control of two blowers, for cooling an enclosed space, in a Raspberry Pi running Python 2.7 and MySQLdb. I want to store 21 columns of data at 1 row ...
0
votes
0answers
91 views

command “python setup.py egg info” failed with error code 1 in ~~

[root@myserver bin]# pip3.5 install MySQL-python Collecting MySQL-python Using cached MySQL-python-1.2.5.zip Complete output from command python setup.py egg_info: Traceback (most recent ...
0
votes
0answers
15 views

What takes MySQLdb's method 'execute' so long?

With MySQLdb, I iteratively select some data from remote server with this statement: cursor.execute(sql_sel_prj,(start,start+1000)) At the begin, it is ok, but some time later,it is blocked at this ...