Hello,
I am trying to insert values in a MySQL table using Python as front end, but facing this problem.
table structure:-(Name:- namespace)
Fields
prifex-----------------varchar(20)
namespace--------varchar(100)
Code:-
Output:-
--------------------------------------------
(default,<http://Demo:Remo@172.2 1.107.145:8080/SfleXProd/#>)
--------------------------------------------
_mysql_exceptio ns.ProgrammingE rror: (1064, "You have an error in your SQL syntax
; check the manual that corresponds to your MySQL server version for the right s
yntax to use near '<http://Demo:Remo@172.2 1.107.145:8080/SfleXProd/#>)' at line
1")
Problem:-
I am using variable names instead of literal values in the insert statement & not getting the correct syntax, although when I am using literal values i am getting the success.
plz help me that how to use variable names in insert query.
I am trying to insert values in a MySQL table using Python as front end, but facing this problem.
table structure:-(Name:- namespace)
Fields
prifex-----------------varchar(20)
namespace--------varchar(100)
Code:-
Code:
global prefix_dict
global dbConn
keys=[]
i=0
prefix=''
nmspace=''
keys=prefix_dict.keys()
while i<len(keys):
prefix=keys[i]
nmspace=prefix_dict[keys[i]]
s="""("""+str(prefix)+""","""+str(nmspace)+""")"""
print "--------------------------------------------"
print s
print "--------------------------------------------"
s1="""INSERT INTO namespace VALUES"""+s
print s1
dbConn.query(s1)
i+=1
--------------------------------------------
(default,<http://Demo:Remo@172.2 1.107.145:8080/SfleXProd/#>)
--------------------------------------------
Code:
INSERT INTO namespace VALUES(default,<http://Demo:Remo@172.21.107.145:8080/SfleXProd/#>)
dbConn.query(s1)
; check the manual that corresponds to your MySQL server version for the right s
yntax to use near '<http://Demo:Remo@172.2 1.107.145:8080/SfleXProd/#>)' at line
1")
Problem:-
I am using variable names instead of literal values in the insert statement & not getting the correct syntax, although when I am using literal values i am getting the success.
plz help me that how to use variable names in insert query.
Comment