mysql-python

What's the difference between MySQLdb, mysqlclient and MySQL connector/Python?

What's the difference between MySQLdb, mysqlclient and MySQL connector/Python? Question: So I’ve been trying to do some database update with python and while setting up the whole dev environment, I came across these three things which made me dizzy. There’s MySQLdb There’s mysqlclient And then there’s a mysql connector python What’s each of them, the …

Total answers: 5

Python MySQLdb type error while using execute with %s

Python MySQLdb type error while using execute with %s Question: I’ve started with a simple mysql query in python, returning all the columns of the table. For some reason this command works: cursor.execute(“SHOW columns from students”) While all of the following return a type error: cursor.execute(“SHOW columns from %s”, ‘students’) cursor.execute(“SHOW columns from %s”, (‘students’,)) …

Total answers: 2

TypeError: 'dict' object does not support indexing

TypeError: 'dict' object does not support indexing Question: I’m working on this piece of code, python 2.6.6, old version because I will have to execute this script on linux servers(probably centOS 6, or Debian) with base repositories(stable) installed and no permission to install software that’s not on these repos. This snipped take care to select …

Total answers: 1

How to create a mysql connection pool or any better way to initialize the multiple databases?

How to create a mysql connection pool or any better way to initialize the multiple databases? Question: In my code I am opening two mysql connections and using HTTP requests to insert data into database g.db = mysql.connector.connect(user=a ,password=password, host=localhost,database=mysq1) g.db1 = mysql.connector.connect(user=b,password=password, host=localhost,database=mysql2) @app.route(‘/user/<db>’) def insert(db): #code for inserting data into mysql1 database #code …

Total answers: 3

UnboundLocalError: local variable 'cursor' referenced before assignment

UnboundLocalError: local variable 'cursor' referenced before assignment Question: So I am a newbie but working on a registration system form in flask/MYSQL I am receiving this error (UnboundLocalError: local variable ‘cursor’ referenced before assignment) After hours of playing with the code and research I need your help. This is my file, please let me know …

Total answers: 2

Why do I need to reconnect to the database to see changes in table data?

Why do I need to reconnect to the database to see changes in table data? Question: I periodically query a MySQL table and check data in the same row. I use MySQLdb to do the job, querying the same table and row every 15 seconds. Actually, the row data changes every 3 seconds, but the …

Total answers: 2

mysql-python install error: Cannot open include file 'config-win.h'

mysql-python install error: Cannot open include file 'config-win.h' Question: I am trying to run pip install mysql-python connector but it keeps giving me an error “Cannot open include file: ‘config-win.h’“. The installation works fine on my Mac and another Windows machine, but not this one. I have downloaded Visual Studio C++ and tried installing as …

Total answers: 8

Python3 + MySql: Error loading MySQLdb module: No module named 'MySQLdb'

Python3 + MySql: Error loading MySQLdb module: No module named 'MySQLdb' Question: 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 work. When I try …

Total answers: 5

Python 3.4.0 with MySQL database

Python 3.4.0 with MySQL database Question: I have installed Python version 3.4.0 and I would like to do a project with MySQL database. I downloaded and tried installing MySQLdb, but it wasn’t successful for this version of Python. Any suggestions how could I fix this problem and install it properly? Asked By: Srdan Ristic || …

Total answers: 11

mysql_config not found when installing mysqldb python interface for mariadb 10 Ubuntu 13.10

mysql_config not found when installing mysqldb python interface for mariadb 10 Ubuntu 13.10 Question: 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 went to update that and got: “mysql_config not …

Total answers: 7