SQL script with multiple DB data outputs

I have a complicated sql query script, which I want to execute on several dbs output. But sql executor can take only one db data.
Can someone help me with this?

Hi @Pavlov_Alexey , welcome to the KNIME community

Iā€™m assuming that each of those DB Writers is writing to a different table. Is the problem that you are wanting them to all be able to write at the same time? In the above screenshot, only one of your DB Writers can write at any given moment, and the others will be blocked until it completes. This is a feature to my knowledge of all relational databases, as on any one connection there can be only a single query running at one time. It would be difficult/impossible to allow multiple concurrent processes within the same connection and yet maintain proper transactional state within the database.

I believe you can have more than one connection open to an H2 database at the same time, so if none of your database inserts are dependent on any of the others, you could increase the number of H2 Connector nodes, and attach a DB Writer to each. What happens if you do that?

Is that your actual question? It wasnā€™t clear. You mentioned a ā€œcomplicated sql query scriptā€, but havenā€™t given any details about that.

2 Likes

Right now I came up with this solution. I create local database and then connect to it. And so I can run query.
But if thereā€™s more simple solution. let me know/
Thanks

1 Like

Thanks, itā€™s useful to use multiple connectors.
Actual problem is that I have query that joins three of output db tables.
So I want to make something like this:
image
But cannot connect several db data outputs to one query executor

Hi @Pavlov_Alexey ,

You seem to be wanting to join tables using SQL Executor, but that isnā€™t what SQL Executor is used for. Which is why Iā€™m confused about what you are trying to do.

If your data is in spreadsheets, then putting them into a local database to query them, as you are doing, is a reasonable way forward, but then youā€™d normally query them using something like a DB Query Reader, or with the ā€œin databaseā€ nodes. But equally, you could just use KNIME nodes to read the spreadsheets and join them using multiple joiner nodes or other mechanisms.

But from what you said, putting the data into an H2 database appears to be a workaround for some bigger problem you are facing, yet you havenā€™t described really what this problem is. Can you take a step back and give more detail about the overall problem you are trying to solve?

Hi.

I think each DB writer node must create one table and must not be executed in paralel, but in sequence.

So, split your SQL code. Each step (DB writer) must create one table.

Step_one creates table t1
Step_two creates table t2 (depending on t1)
Step_three creates table t3 (depending on t2 and t1.)
etc.

And the sequence of execution must be granted by variable ports.

Variable outport of step_one connects to variable inport of step_two.
Variable outport of step_two connects to variable inport of step_three
etc.

This assures the sequence of execution
Please try it.
Regards

@Pavlov_Alexey there is this example

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.