0
votes
0answers
12 views

Merging data in database using python

Please tell me a function in python through which I can merge all the results present in my SQL database. import MySQLdb import MySQLdb.cursors import re ...
0
votes
0answers
6 views

Python Database API Cursor.Description wont include Table name

The Database API docs are here http://www.python.org/dev/peps/pep-0249/#description If I use MySQLdb to do a Table Join in python, then there may be problems, def query_db(query, args=(), ...
1
vote
2answers
25 views

Dynamic length of sql args

I have the following: sql = 'INSERT INTO home_title VALUES (%s, %s, %s, %s, %s)' However, the length of arguments is 57. How would I dynamically create the (%s, %s, ...) based on multiplying by 57? ...
0
votes
1answer
16 views

Any help on cursor.execute and urljoin?

I'm getting: exceptions.TypeError: not all arguments converted during string formatting from this: cursor.execute("SELECT * FROM `item` WHERE `url` = %s", (urljoin( base_url, item_url ) )) ...
0
votes
1answer
10 views

Web2Py SQLFORM.Grid

I'm just starting out on the web2py and really can't get pass the SQLFORM.grid part. My data is in mySQL db and i'm trying to call a query for it. I defined the table but without the id field because ...
1
vote
1answer
12 views

parsing MySQL database with python MySQLdb to extract hashtags

I have tweets scraped in MySQL database and I manage to connect to it and query for column that contains tweets' text. Now what I want to do is parse this and extract hashtags into a csv file. So ...
0
votes
1answer
17 views

Exception Handler Not Working: Commiting to SQL Database with SQLAlchemy in Python

I am trying to commit entries to a MySQL database using SQLAlchemy in Python. The function below was meant to allow me to commit a batch of entries, even if one or two of them contained errors that ...
0
votes
3answers
30 views

Database structure in Django for voting app

I'm trying to wrap my head around how I would structure my database tables in the Django webapp I'm writing. I'm a relative newbie to web development, but this is the very first time I've tried to ...
1
vote
1answer
26 views

django postgresql query not working

I have a postgreSQL database that has a table foo that I've created outside of django. I used manage.py inspectdb to build the model for table foo for me. This technique worked fine when I was using ...
1
vote
1answer
37 views

SQLAlchemy insert, update precondition (consistency check)

I would like to keep an invariant when inserting into or updating an 'interval' many-to-many relation using SQLAlchemy. The goal is to make sure that there are no overlapping intervals in the table ...
1
vote
3answers
38 views

How to create relationship many to many in SQLAlchemy (python, flask) for model User to itself

I need to create a table called friends, it should looks like: friends: user_id friend_id I was trying to do this with tutorials from SQLALchemy, but I have not found how to make relation ...
0
votes
1answer
14 views

Python Mysql Load data in file

I have a database with columns like this Col1 Col2 Col3 Col4 Col5 And i have two csv files which has data like this File-1 Column1, Column2, Column4, Column5 1,2,4,5 1,2,4,5 1,2,4,5 1,2,4,5 ...
0
votes
0answers
11 views

Why should I use 'callproc' instead of 'execute' for calling procedures in pymysql?

What is the crucial difference between cursor.callproc('my_procedure') and cursor.execute('CALL my_procedure()') ? I'm asking because it seems that callproc doesn't return field names needed ...
-1
votes
0answers
25 views

Django, MySQL, and Python project architecture [on hold]

I’m currently have a cron job that kick off and send out reports everyday. However, these data is not persistent and not viewable (only through email report). I want to build a Django backed website ...
0
votes
0answers
16 views

Can I connect to my external server with MySQLdb?

import MySQLdb as mdb db = mdb.connect("localhost", "####", "####", "####") is the way to connect to a database on your local machine. But my goal is to connect to my external server. I have my ...
0
votes
1answer
14 views

Updating/Marking duplicate entries with SP's in MySQL

I wrote a program in Python3 that generates alot of data, I want to store this data in MySQL using a python script that calls Stored Procedures that contain queries to do stuff. I have a very large ...
0
votes
1answer
16 views

What is the equivalent of psycopg curs.mogrify on mysql?

What would be the equivalent of psycopg's cur.mogrify on mysql? From: http://initd.org/psycopg/docs/cursor.html mogrify(operation[, parameters]) Return a query string after arguments binding. ...
0
votes
1answer
26 views

error: MySQL_python: does not support sharing connections between threads

I am new in Python, I need to run my rails project which depends on Python app. I am using Python with Mysql and try to run the server but it throws an error: 17:41:41 affiliates.1 | ...
0
votes
0answers
17 views

SQLAlchemy problems when using very long connection string

I'm using a connection-string/DSN with a really long hostname. SA seems to not like it. I've sanitized the error/trace, below. Debugging is made difficult by the fact that this error is raised within ...
2
votes
1answer
42 views

mysql left join : data from left table duplicated for every match

I have a simple structure like so: Challenges table id | title ----------------- 5 | My challenge woo Goals table id | title | challenge_id ------------------------------------- 35 | ...
0
votes
0answers
20 views

How to append a FromClause to a Select by joining on SQLAlchemy

I'm constructing accumulative selects. For example: from sqlalchemy import sql query1 = sql.select( [table1, table2], from_obj=table1.join(table2, table1.c.id == table2.c.fk)) # Do things ...
0
votes
2answers
60 views

C++, Python or PHP, infinitive loop

So I need create some execution loop to do some stuff using mysql and xml (parse it). For this i was need do it using PHP, but as everybody (php devs) know php has time limit for script execution. So ...
0
votes
2answers
19 views

Advice for platform base for an online DAM style system [closed]

I know my title was a little generic but I'm after advice on what platform my system should use. To give you a little more detail, the system is to be web accessed and mixes a DAM (digital asset ...
0
votes
0answers
19 views

Separate session objects for separate REST requests in SqlAlchemy?

I am using sqlalchemy (with MySQL as database) with cherrypy. I have created an engine which is application-wide. I read from SqlAlchemy Sessions Doc that sessions are not thread-safe. Does that mean ...
0
votes
0answers
11 views

Skip/continue past fatal errors with MySQLdb (Python)?

I'm currently trying to make a Rails app that uses the Apple Epf Importer (written in Python, using the MySQLdb module) to import data from the iTunes data feed. For the last few weeks the imports ...
1
vote
1answer
84 views

Sqlalchemy sometimes can not get data

I have a database named weixin_db and there is a table named nvi_instance in it. This is detail : mysql> desc instance; +--------------+------------------+------+-----+---------+----------------+ ...
4
votes
1answer
42 views

How to use UUIDs instead of integers in MySQL DB

I would like to use python's uuid() function to assign my MySQL id's instead of just an integer and AUTOINCREMENT. However, it would also be nice if that uuid() was generated when an object is ...
0
votes
0answers
12 views

Python Mysql insert mass assignment

Is there a way to mass assign in python mysql? I have all this data: uniqueId = user_profile[1] userName = user_profile[2] email = user_profile[3] password = user_profile[4] salt ...
0
votes
3answers
40 views

Select records incrementally in MySQL and save to csv in Python

I need to query the database for some data analysis and I have more than 20 millions records. I have limited access to the DB and my query times out after 8 mins. So, I am trying to break up the query ...
0
votes
0answers
15 views

Callproc function doesn't work with bytes parameters

I'm trying to call a stored procedure from mysql database, the stored procedure is fine, the problem is that i can't call it if the store procedure has a binary parameter. the callproc method throw ...
-3
votes
0answers
24 views

Create list of objects in Python automatically

Is there any framework or best way to create a list of objects with the objective result of the query run in mysql or so below is the one? example in java: listObjetc = ArrayList<Object>; rs ...
2
votes
2answers
45 views

“A foreign key constraint fails” when converting a table from InnoDB to MyISAM

For some reason, the MySQL tables in my Django web application are using different formats, and it is causing foreign key constraint errors (like in this question). Here is what the table formats ...
0
votes
0answers
34 views

PHP: No rows returned from MySQL database?

I'm encountering a problem when retrieving rows from a MySql database with the InnoDB engine. First, I prepare about 50 random alphabetic inputs of several kilobytes each: inputs <- generate(50, ...
1
vote
1answer
29 views

python & Mysql: unsupported operand type(s) for -: 'int' and 'tuple'

I would like to fetch a record from a table and put it in the variable "gl". if value is bigger or smaller then value+-gl it should write into the database import MySQLdb import time import string ...
0
votes
1answer
24 views

error in sql syntax for python and mysql on insert operation

I am trying to execute following similar type 2 sql queries. While one query is executing successfully but other is giving error db = MySQLdb.Connection(host="192.168.1.90", port=3306, user="some", ...
0
votes
0answers
28 views

Sqlalchemy get data after a long time

In openstack , I use below code to store IP address successfully : ''' Now, just insert randomly IP v4/v6 address ''' from horizon.conf import nvi_db nvi = nvi_db.Nvi_Instance() guest_uuid = ...
0
votes
1answer
41 views

Dealing with data from MySQL using Python

I'm a quite new to both Python and MySQL so I hope someone could help me a bit. Here is what I'm having trouble with. I have to use Python to do some analysis and visualization with data fetched from ...
0
votes
0answers
34 views

Python MySQL with Django virtualenv

This has been driving me nuts. This is pretty much what I thought was a standard setup. I've a website in django that's being served just fine. I'm doing a few upgrades and am setting up a test ...
0
votes
2answers
25 views

sqlalchemy's UnicodeText column is giving me a str on my MySQL table; shouldn't it be unicode?

Let's say I have a simple table: class MyTable(...): __tablename__ = 'my_table' id = ... unicode_col = Column(UnicodeText()) Now I would like to get some data out of it: assert ...
0
votes
1answer
20 views

Python - PyQt - QTable Widget - Add Value, Not Key

This post contained nearly the solution I was looking for, but not quite. I have data that I retrieve from MySQL, which resides in what I think is a tuple, though it also looks like a dictionary: ...
0
votes
1answer
21 views

Python wrapper for MySQL configuration tables

I have a set of configuration tables I would like to wrap with python classes. Tables: tbl_counties tbl_cities tbl_streets Each city has country_id it belongs to. Same for street with city. I ...
1
vote
2answers
30 views

Comparing 2 dictionaries in python by lookup

I have 2 lists dictionaries that i have created that have "similar" data in them, basically it works like this: dictionary 1 looks like this: {'category' : category, 'location' : location, 'count' : ...
1
vote
1answer
17 views

using flags in Python MySQLdb

I want to use the python MySQLdb to access a remote MySQL server with --local-infile flag in order to be able to load data from a local file. (as mentioned in this question Importing CSV to MySQL ...
0
votes
1answer
22 views

Creating a MySQL table's columns with a List

New to SO and fairly new to coding, so doing my best to follow the appropriate protocols. In my python script, I'm creating a new table and populating column names from a list, named 'dups'. dups = ...
0
votes
1answer
124 views

Django on Google App Engine with Cloud SQL in dev environment

I am trying to create an application with Django on GAE and CloudSQL as the db. I used this google developers link and this link for setting up the dev-environment. I am not able to connect to local ...
0
votes
1answer
31 views

Retreive MySQL multiple Query with PHP and Process

So far I have this code: <?php include('config.php'); $sql = "SELECT senderID as receiverID, msg, time FROM msg WHERE senderID = 1"; $result = mysql_query($sql); if (!$result) { ...
0
votes
1answer
21 views

Error with MySQL in Python

I impored MySQLdb to use in python but i am getting the following error: File "test.py", line 76, in <module> db = Database() File "test.py", line 18, in __init__ self.connection = ...
1
vote
1answer
21 views

Can I use the same cursor while looping through it?

I am iterating through a SELECT result, like this: import MySQLdb conn = MySQLdb.connect(host = 127.0.0.1, user = ...) # and so on cur = conn.cursor() cur.execute("SELECT * FROM some_table") for ...
0
votes
2answers
34 views

Fetch data order by whole numbers instead of order by each digit of a number

When I am using ORDER BY in mysql query it's ordering by each digit of a number. For ex: Using the normal ORDER BY in my query I am getting this result 101, 103, 104, 105, 12, 123, 125, 13, 131, 134 ...
0
votes
1answer
11 views

how to make session.expunge_all() work to detach all instances from session in SQLAlchemy?

I have created a SQLAlchemy session as: from sqlalchemy.orm import sessionmaker Session = sessionmaker() Session.configure(bind=engine) session = Session() session.autoflush = False I am using the ...

15 30 50 per page