his is an extension of the DB-API 2.0 specification.
This object provides an interface to the Sybase bulkcopy functionality.
| [data]) |
CS_BLK_IN then the
sequence passed as the data argument is sent as one row to the
server. If the direction is CS_BLK_OUT then one row will be
returned from the server. If there are no more rows, None is returned.
| ) |
| ) |
done() must be called (or the
Bulkcopy object destroyed) to flush any outstanding cached rows
to the DB. In addition, any other operation on the associated
Connection object will fail until done is called.
| ) |
Bulkcopy object should be created with the
CS_BLK_OUT direction argument. Intermixed use of the iterator
returned from __iter__ and the rowxfer to
retrieve rows is supported; both use the same underlying function and
will return all rows without missing or duplicating any row.
| ) |
| T) |
| A) |
An example of using the Bulkcopy class follows:
from Sybase import *
c = connect('server', 'user', 'password', bulkcopy=1, auto_commit=1);
c.execute("Create table #b(a int, b varchar(10), c float)")
b = c.bulkcopy('#b') # CS_BLK_IN is default
for r in range(32):
b.rowxfer([r, ("xxx%d" % r), r * 0.1])
if r % 5 == 4:
ret = b.batch()
print "post batch, batch was", ret, "count = ", b.totalcount
ret = b.done()
print "post done, last batch was", ret, "count = ", b.totalcount
for r in c.bulkcopy('#b', out=1):
print r