print function in python3.1

Anjanesh Lekshminarayanan mail at anjanesh.net
Mon Nov 23 14:07:57 CET 2009


Python 3.1.1

sql = "INSERT INTO `tbl` VALUES (NULL, '%s', '%s', '%s', '%s', '%s');"
for row in fp:
    print (sql, (row[0],row[1],row[2],row[3],row[4]))
.
INSERT INTO `tbl` VALUES (NULL, '%s', '%s', '%s', '%s', '%s'); ('142',
'abc', '2006-04-09 02:19:24', '', '')
.
Why is it showing %s in the output ?

1. I dont want to sql % () because that doesnt escape the strings
2. I cant use conn.escape_string(r) because Im not connected to a
database. Output script to file and import to database loated
elsewhere.
-- 
Anjanesh Lekshmnarayanan



More information about the Python-list mailing list