unable to pass argument to mysql query (python)

fosiul01
fosiul01 used Ask the Experts™
on
def Add_Daemon_Record_only(domain_name,domain_id):

 sql_insert_daemon_record = """select test_master_dns_record.domain_id, \
    test_master_dns_record.record_name,test_master_dns_record.type,test_master_dns_record.ttl,\
    test_master_dns_record.data,test_master_dns_record.gtdlocation \
     from test_master_dns_record where test_master_dns_record.data like '78%' \
     and  test_master_dns_record.domain_id = %s """ %(domain_id)
     
   
    cursor.execute(sql_insert_daemon_record)


the error i am getting is :
Traceback (most recent call last):
  File "my_menu.py", line 582, in <module>
    main()
  File "my_menu.py", line 57, in main
    Set_Round_Robin()
  File "my_menu.py", line 332, in Set_Round_Robin
    Add_Daemon_Record_only(row[2],row[0])
  File "my_menu.py", line 471, in Add_Daemon_Record_only
    and  test_master_dns_record.domain_id = %s """ %(domain_id)
ValueError: unsupported format character ''' (0x27) at index 278

can any one please give me the right syntax ??
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
The percent character at like '78%' must be doubled, i.e. '78%%'

Otherwise the apostrophe is not recognised as a character for the template placeholder.
Top Expert 2009

Author

Commented:
thanks great
thats works..

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial