voltrondata / sqlflite

An example Flight SQL Server implementation - with DuckDB and SQLite back-ends.
Apache License 2.0
205 stars 23 forks source link

Connect to duckdb file from external process #13

Closed TaoVonQi closed 11 months ago

TaoVonQi commented 11 months ago

Is it possible to establish a read/write connection to the same duckdb file to perform some write operations and then close the connection?

It seems that the connection is coupled to the state of the server and it does not re-establish a connection every time to allow other external processes to connect-write-disconnect to the same duckdb file.

I have not yet tried it but I'm very eager to do so soon. I'm sorry if that's not the case. My C++ is very rusty.

prmoore77 commented 11 months ago

Hi @TaoVonQi - I see your point, but why not just connect to the Flight SQL Server and perform the operations you refer to? I assume you are running SQL operations against the database, right?

TaoVonQi commented 11 months ago

That makes perfect sense! Thank you! I'm very eager to test this tomorrow with the Grafana flightsql plugin

TaoVonQi commented 11 months ago

I actually need to refresh the duckdb database with newly added parquet files.

I was thinking of running a query like so:

CREATE TABLE t1 AS SELECT * FROM 'test.parquet';

Do you think this will work? I mean it's valid duckdb SQL so it should work right?

prmoore77 commented 11 months ago

yep - that should work - you should probably do CREATE OR REPLACE TABLE t1... if you want the same table name. You should be able to run any DuckDB command (I haven't run into any yet that I cannot run).

TaoVonQi commented 11 months ago

Wonderful! Thank you!!

prmoore77 commented 11 months ago

hi @TaoVonQi - if you are just adding parquet files to an existing directory (appending data) - you could just have a view pointing to the directory - like: CREATE OR REPLACE VIEW parquet_view AS SELECT * FROM '/some_parquet_directory/*.parquet';

That way - you shouldn't have to refresh anything...