Perform a bulk-copy operation on a table with identity columns.
import sybpydb
conn = sybpydb.connect(dsn="user=sa;bulklogin=true;chainxacts=off")
cur = conn.cursor()
cur.execute("create table mytable (empid int identity, empname varchar(20))")
cur.close()
blk = conn.blkcursor()
# Start bulk copy in operation. Do not specify values for identity columns.
# Values will be generated by the server.
blk.copy(name="mytable", direction="in")
blk.rowxfer(["Joanne"])
blk.rowxfer(["John"])
blk.done()
IdStartnum property to specify the initial starting value for identity columns.
# Specify starting identity column value of 11 for the copy operation. blk.copy(name="mytable", direction="in", properties="IdStartNum=11") blk.rowxfer(["Max"]) blk.rowxfer(["Danny"]) blk.done()
Identity property to explicitly specify; the values for identity columns by the application.
# Values for identity columns will have to be specified. blk.copy(name="mytable", direction="in", properties="identity=on") blk.rowxfer([21, "Maya"]) blk.rowxfer([22, "Uma"]) blk.done()