We help IT Professionals succeed at work.
Get Started

unable to pass argument to mysql query (python)

fosiul01
fosiul01 asked
on
533 Views
Last Modified: 2012-06-27
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
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE