9
votes
2answers
8k views

cc1: error: unrecognized command line option “-Wno-null-conversion” within installing python-mysql on mac 10.7.5

This error broke my python-mysql installation on Mac 10.7.5. Here are the steps The installed python is 2.7.1, mysql is 64 bit for 5.6.11. The being installed python-mysql is 1.2.4, also tried ...
9
votes
2answers
8k views

Installing MySQL-python on mac

I am using OSX 10.8 and PyCharm to work on a Python development project. I have installed MySQL-python for the mac using the instructions on the website ...
7
votes
1answer
2k views

python mysqldb multiple cursors for one connection

When you have one connection object, can you make multiple cursors to that one single connection and execute queries with these cursors at the same time? Or would each cursor wait for the previous ...
4
votes
3answers
3k views

Install MySQL-python in virtualenv on Windows 7

I'm trying to install MySQL-python in my virtualenv (Windows 7 32b + Python 2.7.3), but unfortunately after command: pip install MySQL-python I get error message: Install packages failed: Error ...
4
votes
1answer
1k views

Python MySQLdb not inserting data

ubuntu version: 12.10 mysql server version: 5.5.29-0 python version: 2.7 I am trying to use MySQLdb to insert data into my localhost mysql server. I don't get any errors when I run the script but ...
3
votes
1answer
48 views

How to pass dateformat as an argument to the Mysqldb execute method

For escaping the % we can do as below. cur.execute("SELECT DATE_FORMAT(END_DATE, '%%Y-%%m-%%d') FROM CALENDAR_DETAILS", ()) But any idea, how to pass the dateformat to the execute method as below? ...
3
votes
1answer
283 views

Python MySQLdb- using multiple database tables in query

I am writing a script in Python and I am using MySQLdb package. con1 = mdb.connect('127.0.0.1', 'root', '', 'teacher') con2 = mdb.connect('127.0.0.1', 'root', '', 'student', true) I can ...
3
votes
0answers
209 views

Why does SIGINT sent to Python script kill MySQL connection?

I'm having an issue with sending SIGINT's to python scripts which are connecting to a MySQL database using MySQLdb (mysql-python). The python script runs in an infinite loop, and I want to catch the ...
2
votes
1answer
44 views

Python mysqldb fetchmany not working properly

I have some code like this if __name__ == '__main__': def result_generator(cursor, batch_size=10): while True: results = cursor.fetchmany(batch_size) if not ...
2
votes
1answer
344 views

Python 2.7 + Django + MySQL-python error

I installed Python 2.7, Django 1.5.5, MySQL 5.5 on Ubuntu. Then I tried to install SQL driver for python : sudo pip install MySQL-python and the result was Downloading/unpacking MySQL-python ...
2
votes
1answer
708 views

Django - Can we make a connection to different remote database

I am writing a Django application where I already have 1 mysql backend db configured in my settings.py. I know we can add as many db configurations as we want, but that's hard coding which I don't ...
2
votes
2answers
48 views

TypeError when inserting time into xlsxwriter

I'm importing two points of data from MySQLdb. The second point is a time which cursor.fetchall() returns as a timedelta. I had no luck trying to insert that info into xlsxwriter, always getting a ...
2
votes
0answers
757 views

Python MySQLdb - Programming Around SQL Injection Code

First, i'm very new to stack overflow (first question posted) and forums in general. In addition to this downfall, I'm also new to development and databases other than at a Systems Administration type ...
2
votes
0answers
226 views

Copy unicode data from MSSql to MySql in Python error

I am trying to copy unicode data from MSSql to MySql. Below is the code that I am trying for past few days, but unable to do it successfully. #!/usr/bin/python # -*- coding: utf-8 -*- import MySQLdb ...
2
votes
0answers
164 views

How to connect MAMP based MYSQL in Python?

I recently upgraded Python on my Macbook to 2.7 via Macport and eventually I had to upgrade MySQL driver too. I tried to install it via Macport but that guy installed another copy of MySQL server too. ...
1
vote
2answers
246 views

string decode method error in python

I have a function like this: def convert_to_unicode(data): row = {} if data == None: return data try: for key, val in data.items(): if isinstance(val, str): ...
1
vote
1answer
923 views

Error When calling stored procedure in python - Using MySQLdb

I have a MySQL stored procedure called test which accepts one argument. I can execute the stored procedure from python 2.7x using below code data='Teststr' cur = db.cursor() cur.execute("CALL ...
1
vote
2answers
37 views

Convert string to datetime to epoch

I am using Python to query a MySQL table and getting one datetime in string format, which is stored in row[3]. I need to convert this string timestamp to epoch seconds. import MySQLdb import os ...
1
vote
1answer
131 views

Execute MySQL query that access separate databases in Python

I have a MySQL query that accesses 2 databases. I am using Python to execute the query. The problem with Python MySQL connection is that it connects to a single database at any one time like below; ...
1
vote
2answers
182 views

Filter mySQL data while using fetchall(), before passing rows into Excel, via DataNitro

I am trying to simplify this so it will pull any data and lay out without any conflict, but I find errors if I have a date structure with colons and if some of my products have uses of backslash or ...
1
vote
2answers
441 views

Python 2.7.1, codecs, and MySQLdb; why is setting file encoding not needed

I have a small Python program that reads in SQL statements from a file and runs them on a MySQL database. The file is encoded in UTF-8 and the database also uses UTF-8. If I don't set the database ...
1
vote
2answers
1k views

Can't import MySQLdb module in Python

I'm trying to use MySQL in Python. I have installed the MySQL adapter (MySQL-python-1.2.4b4.win32-py2.7) for Python, but when I try to import the MySQLdb module (import MySQLdb) with command prompt I ...
1
vote
2answers
33 views

Not able to get latest rows when re-rerunning same query at regular interval

I am using Python MySQLdb module. I am querying a table every 1 seconds. New rows are being added to this table all the time. The code is as follows; def main(): connectMySqlDb_tagem() ...
1
vote
2answers
352 views

Python Mysqldb returning '\x01' for bit values

Im using Mysqldb with Python(2.7) to return a bunch of values form a Mysql database with a charset latin1. The mysql database has values of type bit(1) when these are returned they look like this ...
1
vote
1answer
188 views

Updating a SQL table with Python 2.7?

I am using Python 2.7 to extract information from webpages (with BeautifulSoup), sort that information and insert it into a SQL table (with MySQLdb). That is quite simple, and I was able to find great ...
1
vote
1answer
47 views

Error when creating table with mysqldb module

I'm trying to create a table with 2 columns using python's mysqldb module, but I get an error, what might be wrong here? cur.execute("CREATE TABLE foreign_crew(id VARCHAR(45) PRIMARY_KEY, surname ...
1
vote
1answer
728 views

Connect to old mysql installation using python-mysql,

I'm trying to connect to database built in into a physical device, and I don't want to change any configuration of this mysql server. When I try to connect i get following error: Traceback (most ...
1
vote
2answers
86 views

Can I combine python's `for` statement with SQL like this: `for id, name, ctime in db.select('table_name', where='…')`

So I'm accessing MySQL from python 2.7 scripts, now I can do this: for id, name, area in db.select('SELECT id, name, area' ' FROM some_table' ' WHERE area IS ...
1
vote
1answer
306 views

Unable to store datetime.datetime.max using SQLAlchemy==0.8.1 with the mysql-python==1.2.4 driver

I've noticed a change in behavior for storing datetime.datetime.max via SQLAlchemy==SQLAlchemy==0.8.1 and going from mysql-python==1.2.3 to mysql-python==1.2.4. By only changing the driver from 1.2.3 ...
1
vote
1answer
237 views

MySQLdb python insert row or increment count on column if exists

I have a simple table in MySQL which looks like this: > ID | username | count What I want to achieve using python is: Add username to table, if does not exist, and set count to 1. Whenever the ...
1
vote
1answer
226 views

Retrieving New Rows of MySQL Database without Restarting App in Python

I created a chat app in PHP using jQuery/AJAX. And now I'm trying to create a Python (2.7.3) app with GUI (Tkinter) that will be used to view and administer chats. I have a MySQL database that stores ...
1
vote
0answers
266 views

Installing MySQLdb specifically in python 2.7 on centos

I'm using CentOS release 6.5 (Final). I 'm currently using python 2.4, in which I can use MySQL without problems. root@dedicado [/home/digicelc/public_html/gestion/python/cater]# python ...
1
vote
2answers
232 views

Countries: A list of their state/province and cities list

I want to get all the countries, their states/province and cities in the world. Where can I find this information? Somebody please help me. I have searched many times, but I couldn't find it ...
1
vote
1answer
1k views

django settings.py syncdb (“Can't connect to MySQL server on (111)”)

I have some sipmlest settings with two servers. On first(192.168.250.199) I have django, and on another(192.168.250.200) i have a mysql server 192.168.250.200:/etc/my.cnf [mysqld] #Base settings for ...
1
vote
1answer
381 views

Scrapy and MySQLdb

I'm using Python 2.7 on Mac OS X Lion 10.7.5. I originally had an issue with installing MySQLdb using both pip-2.7 install MySQL-python as well as downloading and then running python2.7 setup.py ...
1
vote
1answer
116 views

DB-API Type_Codes for Google Cloud Sql: Different from MySQLdb?

I'm finding that the type_codes returned by cursor.description from DB-API are different for Google Cloud SQL than a standard MySQLdb implementation. For example: in MySQLdb (mysqldb-python), ...
0
votes
2answers
57 views

Returning elements from lists within a list

I am trying to select the first element from nested lists within a bigger list. I am trying to return name values out of a MySQL table. I establish a connection to the server and then I do the ...
0
votes
1answer
32 views

Errors in SQL Syntax

I am trying to run MySQL query through a python script and keep getting an error in my SQL syntax, from I can see the query is set up correctly. Could someone please give me a second set of eyes on ...
0
votes
3answers
2k views

mysql connector installed in python 2.6, but not on 2.7

RedHat is my OS. By default it runs python2.6. However, I needed to install python2.7. I installed it following this post. Now, when I run: $ python -V Python 2.7.5 however $ sudo python -V Python ...
0
votes
1answer
9k views

IndexError: tuple index out of range --— Python [closed]

Please Help me. I'm running a simple python program that will display the data from mySQL database in a tkinter form... from Tkinter import * import MySQLdb def button_click(): root.destroy() ...
0
votes
2answers
118 views

Python AppEngine 'import MySQLdb' not working, OS X 10.9.2, python 2.7

I've installed MySQLdb successfully for my system python -- and I've added the library to app.yaml as well, but the dev-appserver does not recognize it. I've followed the tutorial here: ...
0
votes
2answers
74 views

How to avoid crashing python script when executing faulty SQL query?

I am using Python 2.7.6 and MySqldb module. I have a MySQL query that crashes sometimes. It is hard to catch the rootcause for the time being. How can I avoid crashing the python script when executing ...
0
votes
2answers
251 views

Python : How to break the python mysql query line

Currently what i have is.. cursor.execute ("insert into incoming set raw='" + f2 + "', from_em='"+ a2 +"', to2='" + a1 + "'") i am trying to make this easy to read for myself. so i tried to ...
0
votes
1answer
1k views

Fatal error: #include <stdio.h> generated after “pip install mysql-python” command

Like many people, I am having issues getting mysql and python to work together. My specs are: OSX10.9.2 Anaconda 1.9.1 with python 2.7.2, although 2.5 and 2.6 appear to be included MySQL 5.6.16 I ...
0
votes
2answers
763 views

MySQL in Python; connection closes in for loop after first cycle

My MySQL connection closes after one loop cycle. I probably do something wrong in the usage of the mysql object. It outputs one cycle and then exits with an error. This is my code: cnx = ...
0
votes
1answer
14 views

NameError on Script & DB Insert

I am trying to use the Python script here for my own purposes. I'm no Python bloke, so hopefully someone can see what I have wrong. Is it an indent error? Traceback (most recent call last): File ...
0
votes
1answer
37 views

Adding values with Python to Mysql using raw_input

What is wrong with this code? I want to add values ​​to my Mysql database using raw input but I can not do it. The program runs perfectly but when I look into database in mysql none of the data was ...
0
votes
4answers
45 views

MySQL Exact phrase match

I'm using python and the mysqldb module to search a database for a user input. I have tested the python and established a connection to the server and database. It's the SQL code giving me trouble. My ...
0
votes
4answers
111 views

How to save Information in Database using BeautifulSoup [closed]

I'm getting different information for a particular thing and i'm storing those information in a dictionary e.g. {property1:val , property2:val, property3:val} now I have several dictionary of ...
0
votes
1answer
105 views

Python Syntax for Update SQL query

I want to update a table with the following query. I am getting multiple errors on the following. What is the correct syntax for writing the query below cursor.execute("""UPDATE `%s` SET ...