Subject Re: [firebird-support] Re: Firebird Usage Load Problem
Author David Johnson
On Thu, 2005-07-14 at 23:50 +0000, Maurice Ling wrote:
> import kinterbasdb
> connection = kinterbasdb.connect(<connection string>)
> cursor = connection.cursor()
> # inserting data for example
> for line in data:
> cursor.execute(<sql statement>)
> cursor.commit()
>
> # when i'm done
> cursor.commit() # final commit, just in case
> cursor.close()
> connection.close()
>

Is the <sql statement> encoded as a string...

"insert into table (column) values (<<literal value>>)"

or is it parameterized so you can reuse the statement ...


# pseudocode since I don't know the kinterbas or python at all
# and my python book is at work
commitboundary = 5000
transrowcount = 0
cursor.prepare ("insert into table (column) values (?)")
for line in data
increment transrowcount
cursor.setparameters(<<column names>>, <<literal values>>)
cursor.execute()
if transrowcount = commitboundary
cursor.commit

# when i'm done
cursor.commit() # final commit, just in case
cursor.close()
connection.close()



If the former, then the CPU is going towards preparing the statement on
every execution. If the latter, then there is more exploration to be
done.




Prepare is CPU intensive.