Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
like committed Jan 30, 2024
2 parents 156a7ef + 208d91d commit d49190a
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 9 deletions.
30 changes: 23 additions & 7 deletions dbgpt/app/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,36 @@ def _migration_db_storage(param: "WebServerParameters"):
from dbgpt.storage.metadata.db_manager import db
from dbgpt.util._db_migration_utils import _ddl_init_and_upgrade

# try to create all tables
try:
db.create_all()
except Exception as e:
logger.warning(f"Create all tables stored in this metadata error: {str(e)}")
_ddl_init_and_upgrade(default_meta_data_path, param.disable_alembic_upgrade)
# Try to create all tables, when the dbtype is sqlite, it will auto create and upgrade system schema,
# Otherwise, you need to execute initialization scripts to create schemas.
CFG = Config()
if CFG.LOCAL_DB_TYPE == "sqlite":
try:
db.create_all()
except Exception as e:
logger.warning(
f"Create all tables stored in this metadata error: {str(e)}"
)

_ddl_init_and_upgrade(
default_meta_data_path, param.disable_alembic_upgrade
)
else:
warn_msg = """For safety considerations, MySQL Database not support DDL init and upgrade. "
"1.If you are use DB-GPT firstly, please manually execute the following command to initialize,
`mysql -h127.0.0.1 -uroot -p{your_password} < ./assets/schema/dbgpt.sql` "
"2.If there are any changes to the table columns in the DB-GPT database,
it is necessary to compare with the DB-GPT/assets/schema/dbgpt.sql file
and manually make the columns changes in the MySQL database instance."""
logger.warning(warn_msg)


def _initialize_db(
try_to_create_db: Optional[bool] = False, system_app: Optional[SystemApp] = None
) -> str:
"""Initialize the database
Now just support sqlite and mysql. If db type is sqlite, the db path is `pilot/meta_data/{db_name}.db`.
Now just support sqlite and MySQL. If db type is sqlite, the db path is `pilot/meta_data/{db_name}.db`.
"""
from urllib.parse import quote
from urllib.parse import quote_plus as urlquote
Expand Down
4 changes: 2 additions & 2 deletions dbgpt/storage/vector_store/milvus_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, vector_store_config: MilvusVectorConfig) -> None:
self.port = milvus_vector_config.get("post") or os.getenv(
"MILVUS_PORT", "19530"
)
self.username = milvus_vector_config.get("user") or os.getenv("MILVUS_USER")
self.username = milvus_vector_config.get("user") or os.getenv("MILVUS_USERNAME")
self.password = milvus_vector_config.get("password") or os.getenv(
"MILVUS_PASSWORD"
)
Expand Down Expand Up @@ -133,7 +133,7 @@ def __init__(self, vector_store_config: MilvusVectorConfig) -> None:
connections.connect(
host=self.uri or "127.0.0.1",
port=self.port or "19530",
username=self.username,
user=self.username,
password=self.password,
alias="default",
)
Expand Down
43 changes: 43 additions & 0 deletions docs/docs/installation/sourcecode.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,50 @@ Modify the `.env` file to use llama.cpp, and then you can start the service by r
| `llama_cpp_cache_capacity` | None | Maximum model cache size. For example: 2000MiB, 2GiB |
| `llama_cpp_prefer_cpu` | False | If a GPU is available, the GPU will be used first by default unless prefer_cpu=False is configured. |

## Install DB-GPT Application Database
<Tabs
defaultValue="sqlite"
values={[
{label: 'SQLite', value: 'sqlite'},
{label: 'MySQL', value: 'mysql'},
]}>
<TabItem value="sqlite" label="sqlite">

:::tip NOTE

You do not need to separately create the database tables related to the DB-GPT application in SQLite;
they will be created automatically for you by default.

:::


</TabItem>
<TabItem value="mysql" label="MySQL">

:::warning NOTE

After version 0.4.7, we removed the automatic generation of MySQL database Schema for safety.

:::

1. Frist, execute MySQL script to create database and tables.

```python
$ mysql -h127.0.0.1 -uroot -p{your_password} < ./assets/schema/dbgpt.sql
```

2. Second, set DB-GPT MySQL database settings in `.env` file.

```python
LOCAL_DB_TYPE=mysql
LOCAL_DB_USER= {your username}
LOCAL_DB_PASSWORD={your_password}
LOCAL_DB_HOST=127.0.0.1
LOCAL_DB_PORT=3306
```

</TabItem>
</Tabs>


## Test data (optional)
Expand Down

0 comments on commit d49190a

Please sign in to comment.