string - Maximum number of fields for Python .format -


i'm constructing pretty long mysql query using python string.format() method. however, when try use more 10 fields ({0} {10}) tuple out of range error. when use 10 fields ({0} {9}), there's no problem.

i need know how many fields .format() can handle , how address field on #9 if it's possible. thank you!

there isn't limit number of placeholders can use; if index error have miscounted number of elements formatting in. {10} otherwise works fine:

>>> '{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10}'.format(*range(11)) '0 1 2 3 4 5 6 7 8 9 10' 

take account since counting starts @ zero, there eleven elements there.

you should not, however, using str.format() produce sql queries. use sql parameters instead, ensure proper quoting (preventing sql injection security holes), , allow database re-use query plan of queries.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -