I have a database created from
CREATE TABLE `ip` (
`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')
cursor.execute(sql)
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?
sqlstring value for debugging purposes? What does it say (verbatim)? Instead, don't use python string substitution, let it do that for you.