exasol / pyexasol

Exasol Python driver with low overhead, fast HTTP transport and compression
MIT License
72 stars 39 forks source link

Executing multiple statements #72

Closed ghost closed 3 years ago

ghost commented 3 years ago

How about supporting executing multiple statements with one call of execute? The statements could be separated by semicolons. This is e.g. supported by Pentaho Data Integration.

littleK0i commented 3 years ago

No plans to implement this. There are few problems with this feature:

1) Separating queries correctly is harder than it looks.

For example:

SELECT 'abc;cde'
FROM dual;

-- test ; abc ; test
SELECT 'fff;zzz'
FROM dual;;

How many queries are here? It requires a full implementation of Exasol query parser just to isolate individual queries properly.

2) .last_statemet() will no longer work in all cases, since we will be able to run more than one statement at a time.

3) Error handling will be much more difficult. We'll have to add unique query identifier to each query in batch in order to distinguish, which one caused error.

4) Queries are executed sequentially anyway. One Exasol session can run only one query at a time. No performance benefits.


You still can implement a very simple wrapper yourself using .split(), for and .execute(). It will cover most of use cases. But the amount and complexity of edge cases is too high to make it a standard feature.