Skip to content

Commit 0812025

Browse files
committed
add duckdb readonly
1 parent 27285ef commit 0812025

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SQLCollections"
22
uuid = "3934435e-e6e6-4fea-a5c0-3a716143d619"
33
authors = ["Alexander Plavin <alexander@plav.in>"]
4-
version = "0.1.12"
4+
version = "0.1.13"
55

66
[deps]
77
AccessorsExtra = "33016aad-b69d-45be-9359-82a41f556fd4"

ext/DuckDBExt.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ module DuckDBExt
33
using DuckDB
44
import SQLCollections: _copy_impl!, rowtable
55

6+
# XXX: should be upstreamed in https://github.com/duckdb/duckdb/pull/17585
7+
DuckDB.DB(file; readonly::Bool=false) =
8+
if readonly
9+
cnf = DuckDB.Config()
10+
DuckDB.set_config(cnf, "access_mode", "READ_ONLY")
11+
DuckDB.DB(file, cnf)
12+
else
13+
DuckDB.DB(file)
14+
end
15+
616
function _copy_impl!(conn::DuckDB.DB, rows, tblname::Symbol)
717
tmp_tblname = String(rand('a':'z', 50))
818
DuckDB.register_table(conn, rows, tmp_tblname)

0 commit comments

Comments
 (0)