签入版本
This commit is contained in:
+1
-1
@@ -234,7 +234,7 @@ def main():
|
|||||||
|
|
||||||
print("\n操作完成!")
|
print("\n操作完成!")
|
||||||
|
|
||||||
except Exception as e: # noqa: BLE001 - CLI 顶层兜底,输出可读错误
|
except Exception as e:
|
||||||
print(f"\n操作失败: {str(e)}")
|
print(f"\n操作失败: {str(e)}")
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|||||||
+12
-5
@@ -8,13 +8,20 @@ from alembic import context
|
|||||||
from sqlalchemy import create_mock_engine, engine_from_config, pool
|
from sqlalchemy import create_mock_engine, engine_from_config, pool
|
||||||
|
|
||||||
# 将 src 加入 sys.path(与 scripts/init_db.py 一致),使 core / modules 可导入
|
# 将 src 加入 sys.path(与 scripts/init_db.py 一致),使 core / modules 可导入
|
||||||
SRC_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "src")
|
_SRC_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "src")
|
||||||
sys.path.insert(0, SRC_DIR)
|
|
||||||
|
|
||||||
from core.config import SQLALCHEMY_DATABASE_URL # noqa: E402
|
|
||||||
from core.database import Base # noqa: E402
|
def _setup_src_path():
|
||||||
|
if _SRC_DIR not in sys.path:
|
||||||
|
sys.path.insert(0, _SRC_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
_setup_src_path()
|
||||||
|
|
||||||
|
from core.config import SQLALCHEMY_DATABASE_URL
|
||||||
|
from core.database import Base
|
||||||
# 加载全部模型以填充 metadata(create_app 会连带导入所有业务模块)
|
# 加载全部模型以填充 metadata(create_app 会连带导入所有业务模块)
|
||||||
from core.app import create_app # noqa: E402
|
from core.app import create_app
|
||||||
|
|
||||||
create_app()
|
create_app()
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
"""常量与枚举统一入口(原 shared/__init__.py 迁移)。"""
|
"""常量与枚举统一入口(原 shared/__init__.py 迁移)。"""
|
||||||
|
|
||||||
from constants.constants import ( # noqa: F401
|
from constants.constants import (
|
||||||
PAGE_SIZE, # 默认每页显示记录数
|
PAGE_SIZE, # 默认每页显示记录数
|
||||||
DEFAULT_PASSWORD, # 默认密码
|
DEFAULT_PASSWORD, # 默认密码
|
||||||
MESSAGE_OK, # 操作成功提示
|
MESSAGE_OK, # 操作成功提示
|
||||||
@@ -59,3 +59,17 @@ from constants.constants import ( # noqa: F401
|
|||||||
BANNED_UPLOAD_EXTS_MSG, # 禁止上传扩展名提示信息
|
BANNED_UPLOAD_EXTS_MSG, # 禁止上传扩展名提示信息
|
||||||
JWT_SALT_MIN_LENGTH, # JWT 密钥最短长度
|
JWT_SALT_MIN_LENGTH, # JWT 密钥最短长度
|
||||||
)
|
)
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"PAGE_SIZE",
|
||||||
|
"DEFAULT_PASSWORD",
|
||||||
|
"MESSAGE_OK",
|
||||||
|
"MESSAGE_FAIL",
|
||||||
|
"SERIALIZE_EXCLUDE_FIELDS",
|
||||||
|
"SUPERADMIN_ID",
|
||||||
|
"BUILTIN_ROLE_IDS",
|
||||||
|
"BUILTIN_UPLOAD_EXTS",
|
||||||
|
"BANNED_UPLOAD_EXTS",
|
||||||
|
"BANNED_UPLOAD_EXTS_MSG",
|
||||||
|
"JWT_SALT_MIN_LENGTH",
|
||||||
|
]
|
||||||
@@ -134,7 +134,7 @@ def build_engine(driver: str | None = None, database_url: str | None = None):
|
|||||||
|
|
||||||
if drv == 'oracle':
|
if drv == 'oracle':
|
||||||
# 懒加载:仅 oracle 分支需要 oracledb(thin 模式,无需 Oracle Instant Client)
|
# 懒加载:仅 oracle 分支需要 oracledb(thin 模式,无需 Oracle Instant Client)
|
||||||
import oracledb # noqa: F401
|
import oracledb # 副作用:注册 SQLAlchemy Oracle 方言
|
||||||
return create_engine(
|
return create_engine(
|
||||||
url,
|
url,
|
||||||
pool_size=DB_POOL_SIZE,
|
pool_size=DB_POOL_SIZE,
|
||||||
|
|||||||
@@ -9,10 +9,16 @@ from pathlib import Path
|
|||||||
|
|
||||||
# scripts/ 下无 __init__.py,把 scripts 目录加进 sys.path 以便直接 import
|
# scripts/ 下无 __init__.py,把 scripts 目录加进 sys.path 以便直接 import
|
||||||
_SCRIPTS_DIR = Path(__file__).resolve().parents[3] / "scripts"
|
_SCRIPTS_DIR = Path(__file__).resolve().parents[3] / "scripts"
|
||||||
if str(_SCRIPTS_DIR) not in sys.path:
|
|
||||||
|
|
||||||
|
def _setup_scripts_path():
|
||||||
|
if str(_SCRIPTS_DIR) not in sys.path:
|
||||||
sys.path.insert(0, str(_SCRIPTS_DIR))
|
sys.path.insert(0, str(_SCRIPTS_DIR))
|
||||||
|
|
||||||
import init_db # noqa: E402
|
|
||||||
|
_setup_scripts_path()
|
||||||
|
|
||||||
|
import init_db
|
||||||
|
|
||||||
|
|
||||||
def test_oracle_sequence_sql():
|
def test_oracle_sequence_sql():
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
var _hmt = _hmt || [];
|
var _hmt = _hmt || [];
|
||||||
(function() {
|
(function() {
|
||||||
var hm = document.createElement("script");
|
var hm = document.createElement("script");
|
||||||
hm.src = "https://hm.baidu.com/hm.js?c34f7db0847c3d541f8e0b45a855d460";
|
hm.src = "https://hm.baidu.com/hm.js?f03884f6a99768ef6551c03b3850724c";
|
||||||
var s = document.getElementsByTagName("script")[0];
|
var s = document.getElementsByTagName("script")[0];
|
||||||
s.parentNode.insertBefore(hm, s);
|
s.parentNode.insertBefore(hm, s);
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user