Today I ran into a funny situation. I was using sqlite3, this is my first time to use it. I was just to execute a very simple SQL statement, that looks like,
connection.execute('INSERT INTO table_name (column_name) VALUES (?)', 'column_value')

If you have run similar statement, you probably won't forget the result of above statement. I have to admit that I didn't read sqlite3 with much care. I got an error message saying the statement has 1 parameter but I pass 12 parameters to it.

Even you haven't run into this, you probably can guess what the problem is. sqlite3 do len('column_value') without knowing its type. I tried to use another way, tuple, then I found out that I didn't know one fact of tuple.

Now, here is a list, please answer by reading this script:
#!/usr/bin/python

quiz = [
[],
{},
(),
'12345',
[12345],
['12345'],
(12345),
('12345'),
('12345',),
]

for q in quiz:
print '%10s ->' % repr(q),
try:
print len(q)
except Exception, e:
print e

Answers (select them to read):
[] -> 0
{} -> 0
() -> 0
'12345' -> 5
[12345] -> 1
['12345'] -> 1
12345 -> object of type 'int' has no len()
'12345' -> 5
('12345',) -> 1

So here is right way to do:
connection.execute('INSERT INTO table_name (column_name) VALUES (?)', ('column_value',))