Mysql Database query error in python -
my database cannot query. when run code it's show me error .
def button_click(self): # shost qstring object shost = self.le.text() if shost: s_h = "127.0.0.1" s_n = "root" s_p = "" s_d = "code" s_cn = mdb.connect(s_h, s_n, s_p, s_d) cursor = s_cn.cursor() today = datetime.date.today() mac = get_mac() query = "insert `ac` (`acc`, `mac`, `date`) values (%s, %s, %s)" re = cursor.execute(query,(shost,mac,today,)) if re: self.ex = example() self.ex.show() else: query1 = "select * `ac` `acc` = %s,`mac` = $s" ck = cursor.execute(query1,(shost,mac)) if(ck): self.ex = example() self.ex.show() else: print 'no' i want know how write sql code python variable how can fix ?
query = "insert `ac` (`acc`, `mac`, `date`) values (%s, %s, %s)" re = cursor.execute(query,(shost,mac,today,)) and
query1 = "select * `ac` `acc` = %s,`mac` = $s" ck = cursor.execute(query1,(shost,mac))
query1 = "select * fromacwhereacc= %s,mac= $s"
$s - not valid placeholder, replace %s.
Comments
Post a Comment