4

I'm trying to use the IBM query accelerator using the IBM_DB library in Python.

For an insert query I am able to do this in access by adding a "set current query acceleration = enabled;" statement to the top of the SQL code generated by access. I can also remotely query the IBM database from SQL Server management studio using an (execute . . . at) statement by adding that same line above my insert statement. However, when I try to do this in Python using the IBM_DB library, it appears that my insert statement never executes.

I'm using something like this:

import ibm_db
conn = ibm_db.connect("database","username","password")
stmt = ibm_db.exec_immediate(conn, sql_statement)

The sql_statement variable is a string containing my sql code. The sql code inserts from a select statement. When I run this code without the query acceleration line above, it works fine. However, adding the "set current query acceleration = enabled" line above it seems to cause my query not to run.

I expect my query to run with the "set current query acceleration = enabled" line just as it would without it, only faster. This is the result I get when I add that line in access or in a statement I execute on DB2 remotely from sql server management studio. When I query the table inserted on using IBM_DB from Python, it shows the expected results when I don't have the acceleration line up top. When I add the acceleration line, run the Python code, and again query the inserted table the table remains blank.

3
  • There is nothing fancy about Python driver - it is wrapper around CLI interface. It is odd that query simply "doesn't execute". There is no error code reported? I suggest two approaches: 1. Try with native Db2 CLI client (e.g. db2cli) and see if it is OK. 2. Run the code with CLI trace enabled and see if indeed all statements complete with correct sqlcode.
    – kkuduk
    Commented Oct 28, 2019 at 8:16
  • Have you tried running it as two separate statements? Commented Nov 4, 2019 at 12:54
  • I'm seeing the same behavior in our DB2 database. When I run "set current query acceleration = all" and then run the SQL from a database client (using a product called AQT), the query works fine and utilizes Accelerator. However, when I run "set current query acceleration = all" and run the same exact SQL query from python - I get the generic error that shows when trying to run queries with tables that don't exist in Accelerator (-4742). I've kicked the issue over to our DBAs and will see if they have an answer or can contact IBM for it. Commented Dec 8, 2019 at 10:16

0

Browse other questions tagged or ask your own question.