Thank you again for building this! When using an in-memory DuckDB, I haven't run into any issues at all. I am getting an error when using a persistent DB though. I get this error each time I connect, as well as each time that I create a table.
I think that the background refresh may need to reuse the existing connection from within that other thread. To do that, there is a special flag we need to pass in the DuckDB connect method to allow for multi-threaded access. Updating from multiple threads isn't guaranteed to not step on top of each other, but from a brief look it seems like your background thread isn't updating anything, just pulling schema info.
DuckDB connection allowing multiple threads:
duckdb_con = duckdb.connect('my_filename_or_path.db', check_same_thread=False)
The error I'm seeing is below. Since the only issue seems to be the background refresher, everything else is working fine that I have tested so far!
(duckcli) C:\Users\Alex\Documents\DuckDB\scratch_work>duckcli from_duckcli.db
Exception in thread completion_refresh:
Version: 0.0.1
Traceback (most recent call last):
GitHub: https://github.com/dbcli/duckcli
File "C:\ProgramData\Anaconda3\envs\duckcli\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\ProgramData\Anaconda3\envs\duckcli\lib\threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "C:\ProgramData\Anaconda3\envs\duckcli\lib\site-packages\duckcli\completion_refresher.py", line 69, in _bg_refresh
executor = SQLExecute(e.dbname)
File "C:\ProgramData\Anaconda3\envs\duckcli\lib\site-packages\duckcli\sqlexecute.py", line 44, in __init__
self.connect()
File "C:\ProgramData\Anaconda3\envs\duckcli\lib\site-packages\duckcli\sqlexecute.py", line 55, in connect
conn = duckdb.connect(database=db_name)
RuntimeError: IO Error: Cannot open file "from_duckcli.db": The process cannot access the file because it is being used by another process.
from_duckcli.db> select 'test' as testing;
| testing |
|---------|
| test |
1 row in set
Time: 0.010s
Thank you again for building this! When using an in-memory DuckDB, I haven't run into any issues at all. I am getting an error when using a persistent DB though. I get this error each time I connect, as well as each time that I create a table.
I think that the background refresh may need to reuse the existing connection from within that other thread. To do that, there is a special flag we need to pass in the DuckDB connect method to allow for multi-threaded access. Updating from multiple threads isn't guaranteed to not step on top of each other, but from a brief look it seems like your background thread isn't updating anything, just pulling schema info.
DuckDB connection allowing multiple threads:
The error I'm seeing is below. Since the only issue seems to be the background refresher, everything else is working fine that I have tested so far!