Python tuples and Sql query

Reply

Join Date: Nov 2006
Posts: 7
Reputation: sliver_752 is an unknown quantity at this point 
Solved Threads: 0
sliver_752's Avatar
sliver_752 sliver_752 is offline Offline
Newbie Poster

Python tuples and Sql query

 
0
  #1
Apr 7th, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 18
Reputation: sharma_vivek82 is an unknown quantity at this point 
Solved Threads: 0
sharma_vivek82 sharma_vivek82 is offline Offline
Newbie Poster

Re: Python tuples and Sql query

 
0
  #2
Apr 11th, 2007
hi,
as i got you , i think the better way you can use is :
  1. qry = "select %s from %s where %s" %(name,table,filter)
and then you can create your own method to run sql

-VS


Originally Posted by sliver_752 View 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?
Best wishes,
Vivek Sharma
Zope/Python Developer
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC