Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(datasource):add oceanbase support #1622

Merged
merged 9 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions dbgpt/app/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from dbgpt._private.config import Config
from dbgpt.component import SystemApp
from dbgpt.storage import DBType
csunny marked this conversation as resolved.
Show resolved Hide resolved
from dbgpt.util.parameter_utils import BaseParameters

ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
Expand All @@ -31,7 +32,6 @@ def async_db_summary(system_app: SystemApp):


def server_init(param: "WebServerParameters", system_app: SystemApp):

# logger.info(f"args: {args}")
# init config
cfg = Config()
Expand Down Expand Up @@ -105,13 +105,16 @@ def _initialize_db(
from urllib.parse import quote_plus as urlquote

from dbgpt.configs.model_config import PILOT_PATH
from dbgpt.datasource.rdbms.dialect.oceanbase.ob_dialect import ( # noqa: F401
OBDialect,
)
from dbgpt.storage.metadata.db_manager import initialize_db

CFG = Config()
db_name = CFG.LOCAL_DB_NAME
default_meta_data_path = os.path.join(PILOT_PATH, "meta_data")
os.makedirs(default_meta_data_path, exist_ok=True)
if CFG.LOCAL_DB_TYPE == "mysql":
if CFG.LOCAL_DB_TYPE == DBType.MySQL.value():
db_url = (
f"mysql+pymysql://{quote(CFG.LOCAL_DB_USER)}:"
f"{urlquote(CFG.LOCAL_DB_PASSWORD)}@"
Expand All @@ -121,6 +124,15 @@ def _initialize_db(
)
# Try to create database, if failed, will raise exception
_create_mysql_database(db_name, db_url, try_to_create_db)
elif CFG.LOCAL_DB_TYPE == DBType.OceanBase.value():
db_url = (
f"mysql+ob://{quote(CFG.LOCAL_DB_USER)}:"
f"{urlquote(CFG.LOCAL_DB_PASSWORD)}@"
f"{CFG.LOCAL_DB_HOST}:"
f"{str(CFG.LOCAL_DB_PORT)}/"
f"{db_name}?charset=utf8mb4"
)
_create_mysql_database(db_name, db_url, try_to_create_db)
else:
sqlite_db_path = os.path.join(default_meta_data_path, f"{db_name}.db")
db_url = f"sqlite:///{sqlite_db_path}"
Expand Down
2 changes: 1 addition & 1 deletion dbgpt/app/static/404.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbgpt/app/static/404/index.html

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading