mysql-python

Install mysql-python return error in CentOs

做~自己de王妃 提交于 2019-12-03 03:13:05
I want to run a django project on CentOs. I tried to install mysql-python by easy_install and pip but I got error with both of them. I Googled the problem and found some suggestions, but none of them helped me. errors are: _mysql.c:29:20: error: Python.h: No such file or directory _mysql.c:40:26: error: structmember.h: No such file or directory _mysql.c:74: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token _mysql.c:75: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token _mysql.c:76: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’

Using PIP in a virtual environment, how do I install MySQL-python

自古美人都是妖i 提交于 2019-12-03 01:50:28
When I'm in my virtual environment, I attempt to run: pip install MySQL-python This didn't work, so I tried downloading the package and installing it by running: python setup.py install This returns the following error: % python setup.py install ~VIRTUAL_ENV/build/MySQL-python running install install_dir /home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/ running bdist_egg running egg_info writing MySQL_python.egg-info/PKG-INFO writing top-level names to MySQL_python.egg-info/top_level.txt writing dependency_links to MySQL_python.egg-info/dependency_links.txt reading

Installing MySQL-python causes command 'clang' failed with exit status 1 on Mac OS 10.13.15

≯℡__Kan透↙ 提交于 2019-12-03 01:22:23
问题 I have installed tools via xcode-select --install but still show the following error while doing pip install MySQL-python Building wheels for collected packages: MySQL-python Running setup.py bdist_wheel for MySQL-python ... error Complete output from command /Users/vaibhavmule/Envs/switchidea/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/p6/0v0bflxn3t399_qdpnm2z7hc0000gn/T/pip-install-SD9Cgh/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__)

“cannot find -lssl; cannot find -lcrypto” when installing mysql-python using mariaDB library

给你一囗甜甜゛ 提交于 2019-12-02 23:47:34
I'm struggling to install the mysql-python pip either systemwide or in a venv on Ubuntu 14.04 with MariaDB 10 installed. Also tried with MariaDB 5.5 and getting the same error. I don't have this issue with vanilla mysql-server installed. I have the following installed via apt-get: build-essential python-dev libmariadbclient-dev (thats the MariaDB replacement for libmysqlclient-dev) python-mysqldb Originally I thought this was an issue installing this into a venv but I've subsequently noticed mysql-python won't install systemwide either. Below are the cmds I used to install in a venv.

MySQLdb Python insert %d and %s

馋奶兔 提交于 2019-12-02 22:53:23
Precursor: MySQL Table created via: CREATE TABLE table(Id INT PRIMARY KEY NOT NULL, Param1 VARCHAR(50)) Function: .execute("INSERT INTO table VALUES(%d,%s)", (int(id), string) Output: TypeError: %d format: a number is required, not a str I'm not sure what's going on here or why I am not able to execute the command. This is using MySQLdb in Python. .execute is performed on a cursor object. EDIT: The question: Python MySQLdb issues (TypeError: %d format: a number is required, not str) says that you must use %s for all fields. Why might this be? Why does this command work? .execute("INSERT INTO

Python, Brew, and MySQLdb

故事扮演 提交于 2019-12-02 20:56:29
I have been running python from a brew install. I went to install the mysql_python egg with setup tools (standard install according to mysql_python instructions) and it installed to /usr/local/lib/python2.7/site-packages/. The dependencies processed, etc. Then I went to run python console. I can import other things (e.g. import django; print django.VERSION works) but when I import MySQLdb, I get the following error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.4-x86_64

adding a dynamic table name in python

人盡茶涼 提交于 2019-12-02 20:33:26
问题 In the given query I am trying to take table name as input from user: import MySQLdb import csv conn=MySQLdb.connect("localhost","root","","graphdata") c=conn.cursor() a= raw_input("Enter the table name") sql='''SELECT distinct sku FROM %s_management''' c.execute(sql,str(a)) rows=c.fetchall() file=open('mine.csv','a+') for eachRow in rows: print eachRow a=eachRow file.write(str(a)+"\n") file.close() what I wanted was that the compiler should as Enter table name: I should enter the table name

Python MySQLdb - Connection in a class

a 夏天 提交于 2019-12-02 18:33:23
I am making a Python project where I have to seek and retreive data from a database. I tried making a class, in which I declare the connection and do my queries, here is moreless what I have so far. import MySQLdb dbc =("localhost","root","1234","users") class sql: db = MySQLdb.connect(dbc[0],dbc[1],dbc[2],dbc[3]) cursor = db.cursor() def query(self,sql): sql.cursor.execute(sql) return sql.cursor.fetchone() def rows(self): return sql.cursor.rowcount sqlI = sql() print(sqlI.query("SELECT `current_points` FROM `users` WHERE `nick` = 'username';")) So, the main problem is that the variable db and

Fastest way to load numeric data into python/pandas/numpy array from MySQL

二次信任 提交于 2019-12-02 18:29:49
I want to read some numeric (double, i.e. float64) data from a MySQL table. The size of the data is ~200k rows. MATLAB reference: tic; feature accel off; conn = database(...); c=fetch(exec(conn,'select x,y from TABLENAME')); cell2mat(c.data); toc Elapsed time is ~1 second. Doing the same in python, using the several examples found in here (I have tried them all, i.e. using pandas read_frame, frame_query and the __processCursor function): How to convert SQL Query result to PANDAS Data Structure? Reference python code: import pyodbc import pandas.io.sql as psql import pandas connection_info =

MySqlDb throws Operand should contain 1 column(s) on insert ignore statement

半腔热情 提交于 2019-12-02 18:21:51
问题 While looking at some of the websocket methods that stack exchange offers, I wanted to save a few data points into a MySQL database. However, when I attempt to run an executemany command, I get the following error: _mysql_exceptions.OperationalError: (1241, 'Operand should contain 1 column(s)') While looking around SO, I found many examples of this error, but they have dealt with removing parenthesis on SELECT statements. I'm not using a SELECT . I'm attempting to INSERT . A short, contained,