simpli int/str problem

Paolino paolo_veronelli at tiscali.it
Fri Aug 12 11:55:18 EDT 2005


sinan . wrote:
> hi all,
> i have a string and int values in same dictionary like this
> dict = {'str_name': 'etc' , 'int_name' : 112 }
> the error occures when do this
> SQL = "INSERT INTO (`AH`, `BH` ) VALUES ('" + dict['str_name'] + "',
> '" + dict['int_name'] + "')"
> cursor.execute(SQL)
> python does not accep dict['int_name'] in SQL variable but when i
> convert this variable to the str , python accepts but i cannot insert
> that into database because database only accept int in `BH `
> thanks.
Try use:
SQL = "INSERT INTO (`AH`, `BH` ) VALUES 
('%s,%d)"%(dict['str_name'],dict['int_name'])

Paolino

		
___________________________________ 
Yahoo! Messenger: chiamate gratuite in tutto il mondo 
http://it.beta.messenger.yahoo.com



More information about the Python-list mailing list