troubleshooting Question

unable to pass argument to mysql query (python)

Avatar of fosiul01
fosiul01Flag for United Kingdom of Great Britain and Northern Ireland asked on
PythonMySQL ServerLinux
2 Comments1 Solution536 ViewsLast Modified:
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 ??
ASKER CERTIFIED SOLUTION
pepr

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros