logo       

Re: Emulating a sequence: msg#00026

python.db.pysqlite.user

Subject: Re: Emulating a sequence

David Pratt wrote:
> Hi Greg. I tried this before quoting. Here is what I had done and the
> error. Can you spot the problem?
> [...]
> The error:
> cursor.executescript(stmt, (tid_int, user, desc, ext))
> TypeError: function takes exactly 1 argument (2 given)

executescript only accepts a single parameter, a SQL script text.

You don't need to use executescript for executing stuff within a single
transaction.

Simply use two executes on the cursor object and the commit on the
connection object:

con = sqlite.connect(...)
cur = con.cursor()
cur.execute(...) # <-- if a DML like INSERT, UPDATE, ... does a "BEGIN"
cur.execute(...)
con.commit() # COMMIT the transaction

-- Gerhard


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise