Refactoring Table Creation

Rich Shepard <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
   I don't have the proper syntax to insert values into a table when it's
created. In my application there are three tables with text values that are
used in the model; I want to enter those values when the tables are created.

   With the syntax,

           categoryList = ['natural', 'economic', 'societal']
           self.cur.execute("CREATE TABLE category (cat_name TEXT NOT NULL PRIMARY KEY);")
           for i in categoryList:
             self.cur.execute("insert into category (cat_name) values (?)", i)

   I get a pysqlite2 error, "pysqlite2.dbapi2.ProgrammingError: Incorrect
number of bindings supplied. The current statement uses 1, and there are 7
supplied."

   If I make three separate insert statements, it works.

   What is the correct syntax to keep the words in a list and have them
correctly inserted?

TIA,

Rich

-- 
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.(TM)    |            Accelerator
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.