mysql-python

Windows Python2.7 mysqldb installation error

[亡魂溺海] 提交于 2019-11-30 23:59:49
问题 I'm trying to install mysqldb for Python. I'm running "pip install mysql-python" and I keep getting this error: running build_ext building '_mysql' extension creating build\temp.win32-2.7 creating build\temp.win32-2.7\Release C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,'fi nal',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\python27\include -Ic:

python execute many with “on duplicate key update”?

巧了我就是萌 提交于 2019-11-30 19:46:39
问题 I am trying to executemany in python with on duplicate key update, with the following script: # data from a previous query (returns 4 integers in each row) rows = first_cursor.fetchall() query=""" INSERT INTO data (a, b, c) VALUES (%s,%s,%s) ON DUPLICATE KEY UPDATE a=%s """ second_cursor.executemany(query,rows) I'm getting this error: File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 212, in executemany self.errorhandler(self, TypeError, msg) File "/usr/lib/pymodules/python2.6

python mysqldb multiple cursors for one connection

坚强是说给别人听的谎言 提交于 2019-11-30 17:26:56
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 cursor to finish its query? connection type: database=MySQLdb.connect(...) cursor: curs=database.cursor() querying: curs.execute("query") You'll need to open multiple connections. Mysqldb is threadsafe, so each connection will be able to access their respective cursors, queries and result sets without having an effect on the other connections but each thread or process will need its own connection.

How to create a mysql connection pool or any better way to initialize the multiple databases?

廉价感情. 提交于 2019-11-30 15:28:28
In my code I am opening two mysql connections and using HTTP requests to insert data into database g.db = mysql.connector.connect(user=a ,password=password, host=localhost,database=mysq1) g.db1 = mysql.connector.connect(user=b,password=password, host=localhost,database=mysql2) @app.route('/user/<db>') def insert(db): #code for inserting data into mysql1 database #code for inserting data into mysql2 database I am making HTTP requests to select the databases. curl -i 'localhost:5000/user/mysql1' # It is working well, data is getting inserted into the selected database. But I was thinking of

Reconnecting MySQL on timeout

南笙酒味 提交于 2019-11-30 14:10:57
问题 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

pip raises stdio.h not found error on Mac OS X Mavericks (10.9)

眉间皱痕 提交于 2019-11-30 14:08:18
I have tried countless solutions at this point and nothing seems to work. I'm trying to install mysql-python, but this happens with numpy and other packages requiring gcc as well: building '_mysql' extension gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -g -O2 -DNDEBUG -g -O3 -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.6-intel-2.7/_mysql.o -Os -g -fno-strict-aliasing -arch x86_64 In file included from _mysql.c

python: MYSQLdb. how to get columns name without executing select * in a big table?

Deadly 提交于 2019-11-30 09:08:27
I want to get the column names of a table, but there a over million data in it. So I cannot use: cursor.execute("SELECT * FROM table_name") print cursor.description And in sqlite3, I do it this way crs.execute("PRAGMA table_info(%s)" %(tablename[0])) for info in crs: print info But this is not working in python mysqldb. Any one know how to do that? You can use SHOW columns : cursor.execute("SHOW columns FROM table_name") print [column[0] for column in cursor.fetchall()] FYI, this is essentially the same as using desc : cursor.execute("desc table_name") print [column[0] for column in cursor

How to install python2.6-devel package under CentOs 5

五迷三道 提交于 2019-11-30 08:38:56
问题 I need to install mysql-python under python2.6. mysql-python package needs python2.6-devel package that depends on the libpython2.6.so.1.0(64bit) I found on the net some python2.6-devel packages, but can't find libpython2.6 Server architecture is x86_64. Maybe someone have this lib, or know where i can find it. Thanks for help) 回答1: I have the same issue and this wonderful link solved it for me... http://blog.milford.io/2010/08/new-method-for-installing-python-2-6-4-with-mysql-python-on

MySQL-python connection does not see changes to database made on another connection even after change is committed

匆匆过客 提交于 2019-11-30 08:27:21
I am using the MySQLdb module for Python (v1.2.3 precompiled binary for Windows Python 2.7) to read and write data to a MySQL database. Once a connection is open, I can use that connection to observe changes made to the database on that same connection, but do not see changes made using another connection, regardless of whether the other connection is made in Python or there is a change made using the MySQL command line client. In the case where I am making updates using Python, note that I am running the commit() command on the connection. Example of program that inserts new records into a

Trouble Setting Up MySQLdb Module

两盒软妹~` 提交于 2019-11-30 07:44:29
I'm pulling my hair out over here trying to set up MySQLdb on my Mac in order to connect to a remote MySQL server. I have installed the latest C MySQL client libraries I have installed XCode 4 I did naively try to install the module before installing XCode or the client libraries I am attempting to set up the module by running the following commands in terminal: $ sudo python setup.py build $ sudo python setup.py install Both of these commands fail with similar error messages. Here is the first stack trace: running build running build_py copying MySQLdb/release.py -> build/lib.macosx-10.6