Hi,

I have a sql query in which all variables declared as :variable should be 
changed to ${variable}. 

for example this sql:

select * 
from table 
where ":x" = "1" and :y=2
and   field in (:string)
and   time between :from and  :to


should be translated to:

select * 
from table 
where "${x}" = "1" and ${y} = 2
and   field in ( ${string} )
and   time between ${from} and ${to}

As far as I have come is to find the group as (:(.+?)\b)
and than replace it as ${$2} 

(it would be nice if before and after the ${variable} it is always one space)

For opposite change (from ${variable} notation to :variable) I am using:

sql.replace('${', ':').replace('}', '')

Can someone please help?

Regards.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to