mysql-python

Installing MySQL-python without mysql-server on CentOS

丶灬走出姿态 提交于 2019-12-03 09:32:40
问题 I'm attempting to install MySQL-python on a machine running CentOS 5.5 and python 2.7. This machine isn't running a mysql server, the mysql instance this box will be using is hosted on a separate server. I do have a working mysql client. On attempting sudo pip install MySQL-python , I get an error of EnvironmentError: mysql_config not found , which as far as I can tell is a command that just references /etc/my.cnf , which also isn't present. Before I go on some wild goose chase creating

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module:

我们两清 提交于 2019-12-03 08:26:13
I am following the django tutorial, Many have asked the question but I think my situation is bit unique because after installing python-mysql I still get this error when I try to do python manage.py syncdb, I am in a virtualenv since I use macports to manage my python installation I created my virtualenv virtualenv code/vdjango --no-site-packages --python=/opt/local/bin/python prior to this using macports I install django py27-django , but after creating my virtualenv I thought its better that I install django on to virtualenv so I used pip install django==1.5 According to django tutorial I

“cannot find -lssl; cannot find -lcrypto” when installing mysql-python?

☆樱花仙子☆ 提交于 2019-12-03 06:38:23
问题 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

Reconnecting MySQL on timeout

萝らか妹 提交于 2019-12-03 06:34:29
I have a Python program which runs on background for weeks, and does database queries every once in a while. For that, I am using the ORM peewee (version 2.2.1). I am using MySQL as a backend. Lately I've encountered a recurring problem with accessing the DB, usually after days of running the program. The error which is raised by peewee is peewee.OperationalError: (2006, 'MySQL server has gone away') The traceback is deep in peewee . I post it here, but as my virtualenv makes filenames too long, I am shortening them: File ".../local/lib/python2.7/site-packages/peewee.py", line 2910, in save

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

别等时光非礼了梦想. 提交于 2019-12-03 06:00:57
问题 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

Python MySQLdb iterate through table

放肆的年华 提交于 2019-12-03 05:41:18
I have a MSQL db and I need to iterate through a table and perform an action once a WHERE clause is met. Then once it reaches the end of the table, return to the top and start over. Currently I have cursor = database.cursor() cursor.execute("SELECT user_id FROM round WHERE state == -1 AND state = 2") round_id = cursor.fetchone() if round != 5 ...do stuff in a loop but this obviously only keeps looping the first entry. I guess you need to use the for in function to read through the table, but I'm not sure exactly how to do this using mysqldb? This will set the cursor at the beginning of the

SQL multiple inserts with Python

空扰寡人 提交于 2019-12-03 04:41:28
UPDATE After passing execute() a list of rows as per Nathan's suggestion, below, the code executes further but still gets stuck on the execute function. The error message reads: query = query % db.literal(args) TypeError: not all arguments converted during string formatting So it still isn't working. Does anybody know why there is a type error now? END UPDATE I have a large mailing list in .xls format. I am using python with xlrd to retrieve the name and email from the xls file into two lists. Now I want to put each name and email into a mysql database. I'm using MySQLdb for this part.

Python MySQLdb - Connection in a class

旧巷老猫 提交于 2019-12-03 04:33:29
问题 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

Update database with multiple SQL Statments

柔情痞子 提交于 2019-12-03 04:04:07
I am using mysql connector.Python 1.0.9 downloaded from MySQL site. I have a sample table here DROP TABLE IF EXISTS my_table; CREATE TABLE my_table (id INT NOT NULL AUTO_INCREMENT UNIQUE, Shot VARCHAR(4), sec varchar(5), lay VARCHAR(15) NOT NULL, lay_status VARCHAR(15) NOT NULL, blk VARCHAR(10) NOT NULL, blk_status VARCHAR(15) NOT NULL, pri VARCHAR(10) NOT NULL, pri_status VARCHAR(15) NOT NULL, ani VARCHAR(10) NOT NULL, ani_status VARCHAR(15) NOT NULL, status VARCHAR(5) ); INSERT INTO my_table VALUES (1,'SH01','3','1863','yes','1863','yes','P4645','yes','P4557','yes','Over'), (2,'SH02','2.5',

Python's MySQLdb can’t find libmysqlclient.dylib with Homebrewed MySQL

自古美人都是妖i 提交于 2019-12-03 03:17:36
问题 MySQL and Python installed with Homebrew I installed MySQL and Python with Homebrew on OS X 10.10.5 Yosemite. My Python 2.7 is at python -> ../Cellar/python/2.7.9/bin/python with a symlink to it at /usr/local/bin/python . In /usr/local/bin there is a symlink: mysql -> ../Cellar/mysql/5.7.9/bin/mysql The error In the Python shell: >>> import MySQLdb Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/site-packages/MySQLdb/__init__.py", line 19,