Home Python MySQL: Select with default value
Reply: 0

Python MySQL: Select with default value

user969 Published in May 25, 2018, 6:54 pm

I have a database created from

  `idip` int(11) NOT NULL AUTO_INCREMENT,
  `ip` decimal(45,0) DEFAULT NULL,
  `mask` int(11) DEFAULT NULL,
  PRIMARY KEY (`idip`),
  UNIQUE KEY `ip_UNIQUE` (`ip`)

And I've made some insertions into this table

But when I try to execute on python:

sql = "select idip from ip where ip=%s and mask=%s" % (long(next_hop), 'DEFAULT')
idnext_hop = cursor.fetchone()[0]

I get the following error:

    Inserting routes into table routes (1/377)...('insere_tabela_routes: Error on insertion at table routes, - SQL: ', 'select idip from ip where ip=0 and mask=DEFAULT')
1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Does anyone have a clue on what is the problem?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30313 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO