/*
Preparing DDL for test:
SQL> recreate table test_uuid (
CON> uuid char(16) character set octets collate octets,
CON> datavalue integer,
CON> constraint test_uuid_pk primary key(uuid) using index test_uuid_pk
CON> );
SQL> commit;
*/
Test:
#####
import fdb
print fdb.__version__
conn = fdb.connect(dsn='localhost/3309:e30', user='SYSDBA', password='masterke', charset='utf8')
tx=conn.trans()
xcur=tx.cursor()
p_list = [
('57F2B8C7-E1D8-4B61-9086-C66D1794F2D9', 111),
('77F2B8C7-E1D8-4B61-9086-C66D1794F2D9', 222),
]
xcur.executemany("insert into test_uuid(uuid, datavalue) values( char_to_uuid(?), ?)", p_list)
xcur.close()
tx.rollback()
conn.close()
Then launch TRACE and do: python <this_script.py>.
Output in trace will be:
2016-01-05T23:41:22.7180 (876:00C33418) PREPARE_STATEMENT ---------------------------------------------- ######### [ 1 ] ########
e30 (ATT_318, SYSDBA:NONE, UTF8, TCPv4:127.0.0.1)
C:\Python27\python.exe:3760
(TRA_346, READ_COMMITTED | REC_VERSION | WAIT | READ_WRITE)
Statement 28:
-------------------------------------------------------------------------------
insert into test_uuid(uuid, datavalue) values( char_to_uuid(?), ?)
6 ms
2016-01-05T23:41:22.7180 (876:00C33418) EXECUTE_STATEMENT_START
. . .
2016-01-05T23:41:22.7180 (876:00C33418) EXECUTE_STATEMENT_FINISH
. . .
Table Natural Index Update Insert Delete Backout Purge Expunge
***************************************************************************************************************
TEST_UUID 1
2016-01-05T23:41:22.7180 (876:00C33418) PREPARE_STATEMENT ---------------------------------------------- ######### [ 2 ] ########
e30 (ATT_318, SYSDBA:NONE, UTF8, TCPv4:127.0.0.1)
C:\Python27\python.exe:3760
(TRA_346, READ_COMMITTED | REC_VERSION | WAIT | READ_WRITE)
Statement 29:
-------------------------------------------------------------------------------
insert into test_uuid(uuid, datavalue) values( char_to_uuid(?), ?)
0 ms
2016-01-05T23:41:22.7180 (876:00C33418) EXECUTE_STATEMENT_START
. . .
2016-01-05T23:41:22.7180 (876:00C33418) EXECUTE_STATEMENT_FINISH
. . .
Table Natural Index Update Insert Delete Backout Purge Expunge
***************************************************************************************************************
TEST_UUID 1
One may see that PREPARE was made two times which is equal to the number of parameter tuples.
But documentation (
http://www.firebirdsql.org/file/documentation/drivers_documentation/python/fdb/reference.html#cursor ) issues:
===
This function simply calls execute() in a loop, feeding it with parameters from seq_of_parameters. Because execute caches PreparedStatements, calling executemany is equally efective as direct use of prepared statement and calling execute in a loop directly in application.
===