Numbers in SQL statements

Nick Collier nick at src.uchicago.edu
Fri Nov 5 17:20:38 EST 1999


Hi,

I've been creating SQL statements from dictionaries holding the field
name and the new value to insert or update. As might be expected this
new value is often a number. When turning this number into a string in
order to create the sql statement the number will have a "L" appended if
it is a long. Consequently, the resulting SQL might look like the
following:

update myTable
set id_num = 23L
where food = 'spam'

I've been testing if the value is a number whose string representation
ends with "L" and then stripping the "L", but am pretty sure there must
be a better way. If so, any suggestions as to what is?

thanks,

Nick
-- 

Nick Collier
nick at src.uchicago.edu
Social Science Research Computing
University of Chicago
Chicago, IL 60637




More information about the Python-list mailing list