A thread-compatible interface to the popular MySQL database server that provides the Python database API.

learn more… | top users | synonyms (1)

1
vote
1answer
12 views

MySQLdb python insert row or increment count on column if exists

I have a simple table in MySQL which looks like this: > ID | username | count What I want to achieve using python is: Add username to table, if does not exist, and set count to 1. Whenever the ...
0
votes
1answer
16 views

Using MySQLsb module with Pypy compiler

I'm trying Pypy compiler to see if I can speed up my code. Nevertheless, I'm having troubles with MySQLdb module, which Pypy is unable to find. I have read that MySQLdb 1.2.4 should work fine with ...
0
votes
1answer
14 views

python MySQLdb prepared select statement

In python with MySQLdb I am trying to execute the following: cur.execute("select COUNT(*) from adjacency where r = %d and c = %d)" % (curRow, curCol) r and c are integer fields in table adjacency ...
0
votes
1answer
22 views

MySQLdb / Python / LocalHost - Query runs without error but no result

I'm hoping someone can help me? I'm trying to populate a MySQL database using Python 2.7 and the MySQLdb library. I've written the sample script below but no matter what I try, I can't get it to work. ...
0
votes
1answer
10 views

Python: Central storage of Mysql credentials

I have a couple scripts that I am working on that use a MYSQL DB for error logging and setting storage, and I would like a way to centrally and securely store MYSQL credentials for use in different ...
0
votes
0answers
19 views

Python MySQLdb Cursor returns empty results

Here is my code snippet... First I've called __execute_query function to insert some rows and then to select few rows.. However, if executed a select query the function returns None or Empty rows... ...
-1
votes
0answers
13 views

Multiple IF statments MySQL

I'm trying to write a multiple IF statement in MySQL I've tried the following without any luck cursor = database.cursor() cursor.execute(""""UPDATE user SET state = IF(user.state ...
0
votes
0answers
20 views

Hook available for automatic retry after deadlock in django and mysql setup

I am using innoDB table in Django with mysql database. During investigation of error OperationalError: (1213, 'Deadlock found when trying to get lock; try restarting transaction') I came across ...
0
votes
2answers
38 views

warning :data truncated for column 'username' at row 1 when using database mysql with django

I am getting the above mentioned warning data truncated for column 'username' at row 1 I am getting this for my model "suserprofile" with "username" as my first listed field ...
-1
votes
2answers
35 views

Sql query for distinct user id on the basis of highest column value

Please help me to write a Django query and MySql query, I have a Table molesdetails like this: +---+ +--------+ +----------+ +----------+ |id | |user_id | | ref | | set | +---+ ...
0
votes
1answer
33 views

update mysql database based on the value in 2 columns

I have a MySQL database with 4 columns: X_coord, Y_coord, num_pos, num_neg What I want to do is update the num_pos corresponding to a specific location, stored in array called location where ...
0
votes
2answers
33 views

MySQL Avoiding duplicates in table of unknown column headers

So let's say I have csv files which I have no control over: a.csv b.csv c.csv and they all have different header names. I dumped all the data into tables a, b, and c. Now, if I get another a.csv ...
1
vote
1answer
15 views

UPDATE statement error - MySQLdb/Python

I'm testing an UPDATE statement on an existing record in my test table. It looks like this: term = 'example-column' termInserted = term + '_inserted' mostRecentRecord = 6 nResult = 777 ...
0
votes
1answer
13 views

INSERT statement error - MySQLdb/Python

I have the following code: cur.execute("INSERT INTO term_results(%s, %s) VALUES (%s, %s) WHERE results_id = %s", (term, termInserted, nResult, bResult, mostRecentRecord)) term and termInserted are ...
1
vote
1answer
35 views

Using MySQLdb to return values - Python

I have a table called coords and it is defined as: mysql> describe coords; +-----------+--------------+------+-----+------------------+----------------+ | Field | Type | Null | Key | ...
0
votes
0answers
36 views

No LOAD DATA support in stored procedures in MySQL?

Actually I am trying to LOAD DATA in MySQL stored procedure but I am getting MySQL Database Error: LOAD DATA is not allowed in stored procedures. My Syntax is:- DELIMITER // CREATE PROCEDURE ...
-1
votes
2answers
51 views

creating database in python

I have installed mysql for python and running python from command line. I am getting syntax error while creating a database. >>> import MySQLdb >>> CREATE DATABASE chom; File ...
0
votes
0answers
21 views

connections leak in django

Sometimes MySql throws exception _mysql_exceptions.OperationalError: (1203, "User senderma_user already has more than 'max_user_connections' active connections"). Could you help me to ...
-3
votes
0answers
41 views

Installing Mysql-python for Django on windows, error : command 'gcc' failed with exit status 1

I'm getting this error when trying to install Mysql-python for Django on windows. I'm using virtualenv for powershell and wamp for Mysql _mysql.c:42:24: error: config-win.h: No such file or directory ...
0
votes
0answers
26 views

Intellij not seeing python module MySQLdb

I have installed the python mysqldev sudo apt-get install python-mysqldb It is working on command line python. But IJ does not see it File "/shared/git2/etl/appminer/hive/DB.py", line 7, in ...
2
votes
2answers
44 views

MySQL select top 10% of users

I have a simple MySQL db listing the total time spent each user has spent online in seconds (just a string) per day. I would like to select the top 10% of those users for a given day and return there ...
0
votes
0answers
35 views

Simplifying Large SQL Prepared Statements in Python

I've made a Python script to insert some values from Excel Spreadsheets onto a mySQL database. I'm using mySQLdb and prepared statements. I am reading from multiple files with iterators, and each of ...
1
vote
2answers
57 views

Filter mySQL data while using fetchall(), before passing rows into Excel, via DataNitro

I am trying to simplify this so it will pull any data and lay out without any conflict, but I find errors if I have a date structure with colons and if some of my products have uses of backslash or ...
0
votes
1answer
31 views

MySQLdb return `Decimal` for a `sum` of `INT`

This is the table definition I use to reproduce the issue: create table test_sum_type ( kind char(1) not null, n tinyint not null ); Test data: +------+---+ ...
0
votes
2answers
18 views

python mysqldb connect error

My problem occurred as follows: I use the APIs of mysqldb , the codes like this: conn = MySQLdb.connect(host='192.168.1.16', user='henry', passwd='password', db='test', charset='utf8') cur = ...
0
votes
1answer
21 views

Why is python responding to an Android client different depending on the use of a dictionary?

I have been writing an application for Android that receives a response from a cgi-script (python) that access data from a MySQL DB in order to generate dynamic content. I receive the response fine. I ...
0
votes
0answers
14 views

How to install python26-mysqldb on a RHEL5?

I tried to search for the package "python26-mysqldb" using yum but couldn't find the package for installation on RHEL5. Can someone please tell me how do I install the package. Since it is a ...
1
vote
1answer
14 views

Python, mySQLdb: Is it possible to retrieve updated keys, after update?

I am executing an update query using MySQLdb and python 2.7. Is it possible to know which rows affected by retrieving all their ids?
1
vote
0answers
49 views

Django Unknown system variable 'TRANSACTION' on syncdb

My local Django is blowing up running the manage.py syncdb script that runs on our servers. This is the error message I'm seeing when running python manage.py syncdb, OperationalError: (1193, ...
0
votes
0answers
17 views

How can i install 'emma' ( mysql tool ) on centos . in ubuntu it is as simple as “apt-get install emma”. [migrated]

i downloaded the emma from a google result. and then untar-ed it. wget http://www.fastflo.de/files/emma/downloads/python_src/emma-0.6.tar.gz tar -xvzf emma* cd emma* but i can't run ./cofigure ...
1
vote
4answers
55 views

What are the options for storing Python long integers in MySQL?

I need to represent instances of Python "Long integer" in MySQL. I wonder what the most appropriate SQL data type I should use. The Python documentation (v2.7) says (for numbers.Integral): Long ...
0
votes
0answers
25 views

Parameterized MySQLdb SELECT, 1241, 'Operand should contain 1 column(s)

Any ideas on why this is failing? I looked at other similar questions but the had ('s in their queries, this one is simple or I thought. Doesn't matter if I use a named parameter or sequential. query ...
0
votes
1answer
39 views

Python MySQL Update taking 10-12 seconds to update about 1000 records

I have something along the lines of: while True: variables are set - Each loop the variables are different. sql = sql statement with above variables send sql to MySQL server I am able ...
-1
votes
1answer
46 views

Installed new version of python, Now I can't use the libraries I've installed for the older version in Mac

I am using an older version of Python 2.7.3, but I realize that it is a 32 bit version and I needed a 64 bit version to be able to use MySQLdb. Also, I have other libraries that I have downloaded for ...
0
votes
1answer
149 views

Import Specific Column Data into Different MYSQL Tables from CSV using Python

I have a csv file with many columns and I want to import two to one table, ten to another, and ten to another still. How could I modify the code below to be selective like that? I was thinking of ...
1
vote
1answer
34 views

Issue getting csv data into mysql table with python and mysqldb

I've been fighting with this python code for a while and getting various errors when I try to execute. import csv import MySQLdb # open the connection to the MySQL server. # using MySQLdb mydb = ...
0
votes
1answer
23 views

Python-MySQLdb: Difficulty In Creating Table

I am facing a problem while creating a table in mysqldb using python like this: cursor.execute("CREATE TABLE IF NOT EXISTS %s ( tweetId VARCHAR(100) NOT NULL, tweet VARCHAR(180) NOT NULL, PRIMARY ...
0
votes
0answers
10 views

Issue with gcc-4.0 while installing mysql-python on Mountain Lion

I'm trying to install mysql-python, but running into several problems. If I just type: $easy_install mysql-python then I get: EnvironmentError: mysql_config not found I believe I've fixed this ...
1
vote
2answers
79 views

How to fetch top n records for each category [duplicate]

I have a table like below, placed at SQL FIDDLE id empid proj file rating ~~ ~~~~~ ~~~~ ~~~~ ~~~~~~ 1 1863 G1 file1 1 2 P4645 G1 file2 1 3 P6682 G1 file3 1 4 P6682 ...
0
votes
1answer
38 views

How to use other table field in SQL Where clause

I have a scenario were i need to select the rows from one table provided the the condition satisfies in other table. Sorry if i am confusing.... I am using MySQL as database with python 2.6 to ...
0
votes
1answer
22 views

Is it wise to store a list of objects as a variable in another object?

So lets say I have an order which lists multiple items and some attributes like their ID and prices.... My original concept involved treating these objects separately and having the items listed in ...
0
votes
2answers
47 views

Insert datetime.datetime object in MySQL

I'm trying to insert my datettime object into MySQL >>> t datetime.datetime(2013, 5, 21, 19, 33, 36, tzinfo=tzutc()) >>> cursor.execute('INSERT INTO tweets(created_at) VALUES ...
0
votes
0answers
51 views

Why do I get these errors “Data truncated for column”?

I use this string to upload my CSV file into a MySQL table. Query = """ LOAD DATA LOCAL INFILE 'Data to file_name.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY ...
0
votes
2answers
51 views

Using a Python variable in MySQL query

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 ...
1
vote
1answer
50 views

How to get MySQLdb running on Mountain Lion with Python 2.7 and MySQL 5.6.11 x86_64

I have gone through various possibities of installing MySQL following hundreds of advice (e.g. here on stackoverflow) in order to get MySQLdb running. After having installed Xcode and Command Line ...
1
vote
2answers
68 views

How can one optimize this MySQL count algorithm?

I have 2 tables; one is users and the other records user actions. I want to count the number of actions per user and record this in the users table. There are ~100k user and the following code takes 6 ...
0
votes
1answer
67 views

Getting peewee to work on elastic beanstalk

I'm trying to install the peewee package on an elastic beanstalk instance to control a bottle application. I think the problem is with the MySQL-python dependency, but peewee doesn't load either. My ...
0
votes
1answer
44 views

Python 2.6 : How to pass variable to mysql query if it must be placed above application(environ?

The only way to get a variable from the URL is via under the def application(environ, start_response): but the mysql code must be placed on top of this line. what are the known options ? extra ...
0
votes
0answers
21 views

Python MySQLdb returns a list of empty strings on a large query

The MySQL query I'm running returns 2,903,781 items in its result set. When I do the query using MySQLdb in Python, and attempt to get back a list with fetchall(), I get a list that is the correct ...
0
votes
1answer
29 views

using the GetIndex() function

Managed to fix up my code. now thing is I'm trying to call up an event to use the getIndex() to extract the index of the currently selected listctrl item. I know I need to pass a varable for event but ...

1 2 3 4 5 14