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).
-3
votes
1answer
23 views
18
votes
7answers
50k views
Install mysql-python (Windows)
I've spent hours trying to make Django work on my computer. The problem is that I can't install the mysql-python package. I'm running Windows 7 64bit. This is what I've tried:
I have downloaded ...
-3
votes
0answers
28 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
13 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 ...
0
votes
1answer
9 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
26 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
0answers
58 views
multi=True exception on a single query execution
I have a script that read data from mySQL database and after transfer it via socket update that record in the database!
But after each 1000 or 2000 row of good working it raise this kind of error:
...
0
votes
1answer
27 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
21 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 ...
11
votes
5answers
8k views
mysql_config not found when installing mysqldb python interface for mariadb 10 Ubuntu 13.10
After I installed Mariadb 10 the Mysql workbench and JPDB client both connect and work fine so next step was get programming with Python (using SQLAlchemy) which seems to require MySQL-python so I ...
0
votes
1answer
15 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
13 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
27 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
12 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
1answer
16 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
0answers
12 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
24 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 ...
480
votes
30answers
283k views
pip install mysql-python fails with EnvironmentError: mysql_config not found
This is the error I get
(mysite)zjm1126@zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install mysql-python
Downloading/unpacking mysql-python
Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded
...
1
vote
1answer
19 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
22 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
30 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
26 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 ...
21
votes
1answer
20k views
mysql-python install fatal error
I am trying to pip install mysql-python connector but it keeps erroring on me. Works fine on my mac and another windows machine but not this one. I have downloaded visual studio c++ and tried it as 32 ...
2
votes
1answer
6k views
Mysqldb AttributeError: cursor
I am starting to use the mysqldb module in python and I seem to have some issues with the "standard" way of calling queries.
I understand that the standard way is to create a cursor and then use it ...
0
votes
3answers
1k views
PyMySQL error/exception on (file) data load to remote MySQL instance
I am using PyMySQL-0.5.0 and facing an obscure'ish error/exception when loading data from a file to a remote MySQL instance. Upon executing a 'load data local infile ...' statement, I am seeing an ...
1
vote
1answer
83 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 -...
1
vote
1answer
1k views
Django DB transactions and deadlocks
When running Django with Gunicorn with multiple processes/workers I'm getting a deadlock issue with some of my manual MySQL database transactions.
DatabaseError(1205, 'Lock wait timeout exceeded; try ...
10
votes
5answers
13k views
Python3 + MySql: Error loading MySQLdb module: No module named 'MySQLdb'
I am new to Python and trying to setup a Django project to work with MySql. I have read through the documentation as well as some other StackOverflow posts about the topic, but I still can't get it to ...
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
35 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
24 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 ...
28
votes
3answers
14k views
Replacing Pandas or Numpy Nan with a None to use with MysqlDB
I am trying to write a Pandas dataframe (or can use a numpy array) to a mysql database using MysqlDB . MysqlDB doesn't seem understand 'nan' and my database throws out an error saying nan is not in ...
4
votes
2answers
2k views
How to display an SQL string that has been constructed by MySQLDB cursor?
I would like to verify for myself how this MySQL string is translated by the cursor:
cursor.execute("SELECT * from elements where id = %s", (element_id))
Is there a way to get at the computed SQL ...
39
votes
6answers
19k views
Print the actual query MySQLdb runs?
I'm looking for a way to debug queries as they are executed and I was wondering if there is a way to have MySQLdb print out the actual query that it runs, after it has finished inserting the ...
5
votes
4answers
8k views
MySQLdb.cursor.execute can't run multiple queries
We're trying to run SQL files containing multiple insert statements as a single query, but it seems rollback fails when any of the statements contain an error.
MySQLd configuration:
sql_mode = ...
0
votes
3answers
59 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
23 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
30 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 ...
2
votes
1answer
34 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
53 views
Python MySQLdb Lost connection to MySQL server during and uWSGI got Segmentation Fault
When connect.ping() throw MySQL exception: (2013, Lost connection to MySQL server during query), I reconnect MySQL, get a new connection (MySQLdb.connect), then to execute SQL. uWSGI crashed print ...
0
votes
0answers
22 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 ...
0
votes
0answers
16 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 ...
23
votes
6answers
42k views
MySQL: Get column name or alias from query
I'm not asking for the SHOW COLUMNS command.
I want to create an application that works similarly to heidisql, where you can specify an SQL query and when executed, returns a result set with rows and ...
0
votes
0answers
14 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
12 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
232 views
Pycharm MySQLdb 'module' object has no attribute 'Number'
The following program executes well using python script and gives me the expected output :
Database version : 5.6.19-0ubuntu0.14.04.1
However, the exact same program doesn't seem to work on Pycharm....
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 ...
3
votes
2answers
11k views
EnvironmentError: mysql_config not found [duplicate]
EnvironmentError: mysql_config not found, while installing MySQL-python
Could someone advice me on what to do? I did the following from my-side:
Error I got while installing with pip:
ubuntu12....
46
votes
16answers
50k views
“Cannot open include file: 'config-win.h': No such file or directory” while installing mysql-python
I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error reported here, but the answer there worked for me too. Now I'm getting this following ...