İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
4601 Görünümler

Hi all,


In OpenERP 7 , I am using a cr.execute to execute a SQL Request

cr.execute('select distinct(value) from ir_translation where name = \'product.bat3,name\' and src = \''+ str(res_bat[j][0].encode('utf-8'))+'\' and res_id = '+ str(res_bat[j][1])+' and lang = \''+ str(line2.partner_id.lang)+'\'')

However, my string res_bat[j][0] is a string with a quote. The string is: test's Thus I have the error bellow:

ProgrammingError: syntax error at or near "s"
LINE 1: ... where name = 'product.bat3,name' and src = 'test's' and res...

How can I modify my SQL request to correct this error?


Many thanks,


Selverine    

Avatar
Vazgeç
En İyi Yanıt

Hello

as a quick workaround you can use:

res_bat[j][0].replace("'", "''")

So with this double single quotes the postgres can skip the single quote ...

Hope this could helps ...

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
0
May 23
2494
1
Kas 22
6672
2
May 22
2752
1
Eki 21
3779
1
Eki 19
4976