0

I am stuck using python 2.4.3 and the sqlite module issued with that distribution.

How can i run the executemany command in this environment? The more modern syntax seems to have an issue.

import sqlite as sql
conn = sql.connect('test.db')
c = conn.cursor()
c.execute('''create table test(item text)''')
list = ['apple', 'orange', 'banana']

c.executemany('''insert into test values(?)''', list)

Python 2.4.3 is quite old I guess and I can't find any docs, and I have no assoicated doc string associated with the executemany function.

I appreaciate the help.

Paolo
  • 20,112
  • 21
  • 72
  • 113
Zero_Loss
  • 3
  • 3

1 Answers1

0

You should use %s instead of ?:

import sqlite as sql
conn = sql.connect('test.db')
c = conn.cursor()
c.execute('''create table test(item text)''')
list = ['apple', 'orange', 'banana']
c.executemany('''insert into test values(%s)''', list)
Maksym Polshcha
  • 18,030
  • 8
  • 52
  • 77
  • Thanks, but still not quite there. I get TypeError: not all arguments converted during string formatting. I ran code exactly as above. – Zero_Loss Aug 06 '13 at 18:11
  • Got it. In this older version it reads: .executemany('''insert into test values(%s)''', list) – Zero_Loss Aug 06 '13 at 18:18