AlexR2D2 / metabase_duckdb_driver

Metabase DuckDB Driver shipped as 3rd party plugin
Apache License 2.0
75 stars 25 forks source link

Making JDBC connection read-only #9

Closed gouline closed 1 year ago

gouline commented 1 year ago

Would anyone be against making the JDBC connection read-only? From what I understand, Metabase only executes select statements, so it doesn't need write permissions to DuckDB files.

The benefit of a read-only connection is being able to insert data into the file externally (e.g. custom script, dbt transformations) and syncing Metabase without having to restart it. Makes it a powerful tool for local data analysis on your machine.

This page has a Java example:

Properties ro_prop = new Properties();
ro_prop.setProperty("duckdb.read_only", "true");
Connection conn_ro = DriverManager.getConnection("jdbc:duckdb:/tmp/my_database", ro_prop);

Happy to figure out how to do it in Clojure and contribute a pull request, just wanted to ask first.

AlexR2D2 commented 1 year ago

If someone will be against it is possible to add read_only parameters to the DuckDB config page (like database_file).

Also, if user wants to open database in the memory mode, for example just to read parquet files (without native DuckDB database) then read_mode must be false, because DuckDB can't open im-memory DB in read only mode. So, i think we need some kind of check if trim of database_file param is empty then force read_only to false.