mysql-python

Segmentation fault error in a multi threaded app in python

巧了我就是萌 提交于 2019-12-09 03:58:20
问题 I have a multi threaded app in python, wherein I create multiple producer threads and they extract the data from DB. Data is extracted in chunks. So the part where a thread creates sql statement with limit values is kept within lock. And to let threads execute queries simultaneously, query() function is kept outside the lock. Then the result fetching part is again kept under the lock. Below is the code snippet: with UserAgent.lock: sqlGeoTarget = "call sp_ax_ari_select_user_agent_list('0'," +

Issues with Flask-MySQLdb using Python3.7

孤人 提交于 2019-12-08 13:31:21
问题 I am running into an issue with my flask web server. I get an error message once I add from flask_mysqldb import MySQL as well as the SQL script into my source file. I get this message: $ python app.py Traceback (most recent call last): File "app.py", line 3, in from flask_mysqldb import MySQL File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_mysqldb/ init .py", line 1, in import MySQLdb File "/Library/Frameworks/Python.framework/Versions/3.7/lib

Django MySQLdb issue on apache2

浪尽此生 提交于 2019-12-08 13:14:38
问题 i've installed on an ubuntu server django 1.9.4 and mysqlclient, i'm not under virtualenv. If i run manage.py shell or runserver all goes right, but if i try through apache2 and wgi i got this error: ImproperlyConfigured: Error loading MySQLdb module: this is MySQLdb version (1, 3, 7, 'final', 1), but _mysql is version (1, 2, 3, 'final', 0) Python version 3.4 This is the apache2 vhost config: WSGIPythonPath /usr/local/lib/python3.4/dist-packages/:/home/ubuntu/www/mysite DocumentRoot /home

using mysql-python only connects to my router, not my remote server

痞子三分冷 提交于 2019-12-08 09:24:08
问题 using python with module: MySQLdb I attempt to connect to a remote mysql server... conn = mdb.connect('mysql.remotehost.com', 'username', 'password', 'database') rather than try and make the connection to mysql.remotehost.com I get this error: _mysql_exceptions.OperationalError: (1045, "Access denied for user 'username'@'xx.x.xxx.xxx' (using password: YES)") where the xx.x.xxx.xxx is the ip address of my modem/router. Why does this happen? How can I get around it to actually access my remote

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

放肆的年华 提交于 2019-12-08 08:21:23
问题 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 have written a python script where I try to import MySQLdb, or PyMySQL then MySQLdb, neither works. I read many of the threads on stack overflow, and as a result I eventually tried $ export CFLAGS=-Qunused-arguments $ export CPPFLAGS=-Qunused-arguments $ pip install mysql-python The results are below

Moving large SQL query to NumPy

荒凉一梦 提交于 2019-12-08 08:05:49
问题 I have a very large MySQL query in my web app that looks like this: query = SELECT video_tag.video_id, (sum(user_rating.rating) * video.rating_norm) as score FROM video_tag JOIN user_rating ON user_rating.item_id = video_tag.tag_id JOIN video ON video.id = video_tag.video_id WHERE item_type = 3 AND user_id = 1 AND rating != 0 AND video.website_id = 2 AND rating_norm > 0 AND video_id NOT IN (1,2,3) GROUP BY video_id ORDER BY score DESC LIMIT 20" This query joins three tables (video, video_tag,

MySQL Connector/python not working in django

允我心安 提交于 2019-12-08 06:15:26
问题 I'm learning Django with MySQL as backend. I installed Oracle's mysql connector to connect with mysql. However, when I run python manage.py I got this error Traceback (most recent call last): File "C:\Python33\lib\site-packages\django\db\backends\mysql\base.py", line 14, in import MySQLdb as Database ImportError: No module named 'MySQLdb' That's a bit weird. I was thinking if I installed mysql connector/python I dont need MySQLdb anymore. Could anyone help explain? Thanks! My database setting

Can MySQLdb Connection and Cursor objects be safely used from with multiple threads?

回眸只為那壹抹淺笑 提交于 2019-12-07 21:41:45
问题 I'm using mysqlclient v1.3.10 in Python 3.5. After connecting to the database, you get a connection object, from which you get a cursor object that you use to run your queries. Are these objects thread safe (i.e. can I create one set and then share and use them between multiple different python threads)? 回答1: It appears that you can't. The MySQLdb documentation states (scroll down a little further to threadsafety ): The general upshot of this is: Don’t share connections between threads. It’s

Testing AWS Elastic Beanstalk scaling

风流意气都作罢 提交于 2019-12-07 20:44:59
问题 I've set up a server in elastic beanstalk. When required, it is supposed to increase the number of instances from 1 to up to 4. I have a sneaking suspicion, however, that when it starts a new instance that instance won't be properly configured, because I was unable to install the mySQL module for Python without ssh'ing into the instance and setting it up manually, as per this question. So my first question is what is the best way to test that Elastic Beanstalk is scaling correctly? If new

How to share a single MySQL database connection between multiple processes in Python

只谈情不闲聊 提交于 2019-12-07 19:46:53
问题 How can I create a single database connection and have each process talk to it, to minimize the overhead of spawning a new connection with each iteration? Here's some sample code to illustrate what I'm trying to do: import multiprocessing import os.path import hashlib import sys VALID_EXTENSIONS = ('.JPG', '.GIF', '.JPEG') MAX_FILE_SZ = 1000000 #Declare a global mysql connection db = MySQLdb.connect(host="localhost", user=config.mysql_user, passwd=config.mysql_pass, db=config.mysql_db) def