mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-25 19:39:35 +00:00
fix: fix issue #445, sqlite unable to open database file
This commit is contained in:
parent
8a276591d6
commit
e5b03c8ab4
@ -11,6 +11,16 @@ ARG LANGUAGE="en"
|
||||
ARG PIP_INDEX_URL="https://pypi.org/simple"
|
||||
ENV PIP_INDEX_URL=$PIP_INDEX_URL
|
||||
|
||||
RUN pip3 install --upgrade pip -i $PIP_INDEX_URL \
|
||||
&& (if [ "${LANGUAGE}" = "zh" ]; \
|
||||
# language is zh, download zh_core_web_sm from github
|
||||
then wget https://github.com/explosion/spacy-models/releases/download/zh_core_web_sm-3.5.0/zh_core_web_sm-3.5.0-py3-none-any.whl -O /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl \
|
||||
&& pip3 install /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl -i $PIP_INDEX_URL \
|
||||
&& rm /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl; \
|
||||
# not zh, download directly
|
||||
else python3 -m spacy download zh_core_web_sm; \
|
||||
fi;)
|
||||
|
||||
RUN mkdir -p /app
|
||||
|
||||
# COPY only requirements.txt first to leverage Docker cache
|
||||
@ -29,21 +39,11 @@ WORKDIR /app
|
||||
# && pip3 install -r /tmp/requirements.txt -i $PIP_INDEX_URL --no-cache-dir \
|
||||
# && rm /tmp/requirements.txt
|
||||
|
||||
RUN pip3 install --upgrade pip -i $PIP_INDEX_URL \
|
||||
&& cd /app && pip3 install -i $PIP_INDEX_URL .
|
||||
RUN pip3 install -i $PIP_INDEX_URL .
|
||||
|
||||
# ENV CMAKE_ARGS="-DLLAMA_CUBLAS=ON -DLLAMA_AVX2=OFF -DLLAMA_F16C=OFF -DLLAMA_FMA=OFF"
|
||||
# ENV FORCE_CMAKE=1
|
||||
RUN cd /app && pip3 install -i $PIP_INDEX_URL .[llama_cpp]
|
||||
|
||||
RUN (if [ "${LANGUAGE}" = "zh" ]; \
|
||||
# language is zh, download zh_core_web_sm from github
|
||||
then wget https://github.com/explosion/spacy-models/releases/download/zh_core_web_sm-3.5.0/zh_core_web_sm-3.5.0-py3-none-any.whl -O /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl \
|
||||
&& pip3 install /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl -i $PIP_INDEX_URL \
|
||||
&& rm /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl; \
|
||||
# not zh, download directly
|
||||
else python3 -m spacy download zh_core_web_sm; \
|
||||
fi;) \
|
||||
RUN pip3 install -i $PIP_INDEX_URL .[llama_cpp] \
|
||||
&& rm -rf `pip3 cache dir`
|
||||
|
||||
ARG BUILD_LOCAL_CODE="false"
|
||||
|
@ -70,10 +70,10 @@ class SQLiteConnect(RDBMSDatabase):
|
||||
|
||||
def _sync_tables_from_db(self) -> Iterable[str]:
|
||||
table_results = self.session.execute(
|
||||
"SELECT name FROM sqlite_master WHERE type='table'"
|
||||
text("SELECT name FROM sqlite_master WHERE type='table'")
|
||||
)
|
||||
view_results = self.session.execute(
|
||||
"SELECT name FROM sqlite_master WHERE type='view'"
|
||||
text("SELECT name FROM sqlite_master WHERE type='view'")
|
||||
)
|
||||
table_results = set(row[0] for row in table_results)
|
||||
view_results = set(row[0] for row in view_results)
|
||||
|
@ -121,3 +121,17 @@ def test_get_database_list(db):
|
||||
|
||||
def test_get_database_names(db):
|
||||
db.get_database_names() == []
|
||||
|
||||
|
||||
def test_db_dir_exist_dir():
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
new_dir = os.path.join(temp_dir, "new_dir")
|
||||
file_path = os.path.join(new_dir, "sqlite.db")
|
||||
db = SQLiteConnect.from_file_path(file_path)
|
||||
assert os.path.exists(new_dir) == True
|
||||
assert list(db.get_table_names()) == []
|
||||
with tempfile.TemporaryDirectory() as existing_dir:
|
||||
file_path = os.path.join(existing_dir, "sqlite.db")
|
||||
db = SQLiteConnect.from_file_path(file_path)
|
||||
assert os.path.exists(existing_dir) == True
|
||||
assert list(db.get_table_names()) == []
|
||||
|
Loading…
Reference in New Issue
Block a user