mysql-python

error: Setup script exited with error: command 'gcc' failed with exit status 1

时光毁灭记忆、已成空白 提交于 2019-11-28 23:14:09
I get the following error when I try to install MySQL-python-1.2.3 under Python 2.6 in Fedora 14. Fedora 14 comes with Python 2.7 by default and I am working in a project which runs in Python 2.6, So I am not in a position to update Python from 2.6 to 2.7. _mysql.c:35:23: fatal error: my_config.h: No such file or directory compilation terminated. error: command 'gcc' failed with exit status 1 The complete error message is as below [root@localhost MySQL-python-1.2.2]# python setup.py build running build running build_py creating build creating build/lib.linux-i686-2.6 copying _mysql_exceptions

Python mySQL - escaping quotes

孤街浪徒 提交于 2019-11-28 21:33:05
I have seen this question asked in various ways on this website, but none of them exactly addressed my issue. I have an sql statement with single quotes inside it, and am trying to use recommended practices before making database queries with it. So the statement is like val2="abc 'dostuff'" sql="INSERT INTO TABLE_A(COL_A,COL_B) VALUES(%s,'%s')" %(val1, val2) a_cursor.execute(sql) However, when I run this, I get.. ProgrammingError: (1064,"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'dostuff'. What am I

Python: ValueError: unsupported format character ''' (0x27) at index 1

谁都会走 提交于 2019-11-28 19:53:15
问题 I'm trying to execute a query to search 3 tables in a database using MySQL through Python. Every time I try and execute the following string as a query, it gives me an error about concatenation in the string. "SELECT fileid FROM files WHERE description LIKE '%" + search + "%' OR filename LIKE '%" + search + "%' OR uploader LIKE '%" + search + "%' ORDER BY fileid DESC" This is the error it gives me: ValueError: unsupported format character ''' (0x27) at index 1 If I remove the character it

“my_config.h” file not found when intall mysql-python on osx 10.8

时光总嘲笑我的痴心妄想 提交于 2019-11-28 15:58:45
I face this problem when I want to install mysql-python on osx 10.8, it show error with 'my_config.h' file not found. Anyone can help me on that, I am very appreciate on what your contributing, thanks. Below is my running code: sudo easy_install mysql-python Password: Searching for mysql-python Reading http://pypi.python.org/simple/mysql-python/ Reading http://sourceforge.net/projects/mysql-python/ Reading http://sourceforge.net/projects/mysql-python Best match: MySQL-python 1.2.3 Downloading http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5

Python can find a module…and then it can't

丶灬走出姿态 提交于 2019-11-28 14:37:08
I am finally going full steam into Python, but for some reason I have an issue where Python can find a module in the interactive CLI and then it can't when I write a script. The module is specifically mysql.connector located in /Library/Python/2.7/site-packages . As you can see from the interactive CLI session, it imports mysql.connector just fine. Echoing the sys.path shows 'Library/Python/2.7/site-packages' Here's a new CLI window (I'm on a Mac 10.10). Note: initially when I login I am popped into my home dir which of course is normal. wilkie:~ wilkie$ which python /usr/bin/python wilkie:~

Python, MySQLdb and escaping table names?

自闭症网瘾萝莉.ら 提交于 2019-11-28 13:34:50
I may be missing something obvious, but I can't figure out how my code is different from various examples I see in the online documentation for MySQLdb. I'm fairly new to programming python, more experienced with perl. What I'm trying to do is get into certain good habits early on (like in perl I always start with 'use strict; use warnings'), so I'm trying to ensure I create re-usable functions in an independent file (funct.py) to save me time later on down the line. I've got this function for selecting random rows from a table: def returnRandom(conn,countcol,table,field): cursor = conn.cursor

Why isn't the 'insert' function adding rows using MySQLdb?

纵然是瞬间 提交于 2019-11-28 13:33:31
I'm trying to figure out how to use the MySQLdb library in Python (I am novice at best for both of them). I'm following the code here , specifically: cursor = conn.cursor () cursor.execute ("DROP TABLE IF EXISTS animal") cursor.execute (""" CREATE TABLE animal ( name CHAR(40), category CHAR(40) ) """) cursor.execute (""" INSERT INTO animal (name, category) VALUES ('snake', 'reptile'), ('frog', 'amphibian'), ('tuna', 'fish'), ('racoon', 'mammal') """) print "Number of rows inserted: %d" % cursor.rowcount cursor.close () conn.close () I can change this code to create or drop tables, but I can't

mysqldb .. 'NoneType' object is not subscriptable

杀马特。学长 韩版系。学妹 提交于 2019-11-28 13:04:41
This code works fine when the cur.execute() and db.commit() lines are commented out; i.e. if all I do is print the query, this program runs for n number of rows. The problem seems to occur here: player_categories_statistics = cur.fetchone() player_id = player_categories_statistics[0] When I try to insert the result, I get: Traceback (most recent call last): File "test2.py", line 72, in <module> meat = meatgrind(league_name, categories_measurement_statistics) File "test2.py", line 32, in meatgrind player_id = int(player_categories_statistics[0]) TypeError: 'NoneType' object is not subscriptable

MySQLdb.cursor.execute can't run multiple queries

一世执手 提交于 2019-11-28 11:58:58
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 = STRICT_ALL_TABLES default-storage-engine = innodb Python code: from contextlib import closing import MySQLdb database_connection = MySQLdb.connect(host="127.0.0.1", user="root") with closing(database_connection.cursor()) as cursor: database_connection.begin() cursor.execute('DROP DATABASE IF EXISTS db_name') cursor.execute('CREATE DATABASE db_name') cursor.execute('USE db_name') cursor.execute('CREATE

Using a Python variable in MySQL query

浪子不回头ぞ 提交于 2019-11-28 10:49:00
问题 I am trying to write a function that takes the variable written in the function placeholder() written below and then uses that in MySQL queries. I have written up an example below: import MySQLdb connection = MySQLdb.connect(host = "localhost", user = "root", passwd = "", db = "cars") cursor = connection.cursor() def placeholder(placeholder_variable): sql = "TRUNCATE TABLE %s" cursor.execute(sql, placeholder_variable) placeholder('car_brands') When I try to run this program I get the