944,028 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 4328
  • Python RSS
Apr 7th, 2007
0

Python tuples and Sql query

Expand Post »
Hello all,

Is there any algorithm to convert a python tuple to MySql query.

Ex:

('*','name','sliver')

should convert to

select [Pri_Key] from [All Tables] where 'name' = 'sliver';

I have been able to do so ... but my algorithm looks very ugly and have to process everything bit by bit.

The query becomes even more complex when i have nested tuples.


Any Ideas?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sliver_752 is offline Offline
7 posts
since Nov 2006
Apr 11th, 2007
0

Re: Python tuples and Sql query

hi,
as i got you , i think the better way you can use is :
Python Syntax (Toggle Plain Text)
  1. qry = "select %s from %s where %s" %(name,table,filter)
and then you can create your own method to run sql

-VS


Click to Expand / Collapse  Quote originally posted by sliver_752 ...
Hello all,

Is there any algorithm to convert a python tuple to MySql query.

Ex:

('*','name','sliver')

should convert to

select [Pri_Key] from [All Tables] where 'name' = 'sliver';

I have been able to do so ... but my algorithm looks very ugly and have to process everything bit by bit.

The query becomes even more complex when i have nested tuples.


Any Ideas?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sharma_vivek82 is offline Offline
18 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Stuck in GUI
Next Thread in Python Forum Timeline: Find a word in a file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC