feat: 完成 issue #4 数据总线 + 时序库 模板化封装
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Sanity check: data_bus package imports and postgres DDL escaping fix."""
|
||||
import importlib.machinery
|
||||
import importlib.util
|
||||
import os
|
||||
import sys
|
||||
|
||||
d = os.getcwd()
|
||||
|
||||
# 以包身份加载 data-bus(执行 __init__.py,相对导入可用)
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
"data_bus", os.path.join(d, "__init__.py"), submodule_search_locations=[d]
|
||||
)
|
||||
pkg = importlib.util.module_from_spec(spec)
|
||||
sys.modules["data_bus"] = pkg
|
||||
spec.loader.exec_module(pkg)
|
||||
|
||||
from data_bus import BatchWriter, MemorySink, TdengineSink, TemplateNaming, __version__ # noqa: E402
|
||||
from data_bus.postgres_schema import generate_schema_ddl # noqa: E402
|
||||
|
||||
ddl = generate_schema_ddl(TemplateNaming(template="ti-cl4"))
|
||||
assert "DEFAULT '{}'::jsonb" in ddl, "jsonb default escaped wrongly"
|
||||
assert "REFERENCES tpl_ti_cl4.templates(template)" in ddl
|
||||
print("version:", __version__)
|
||||
print("ddl ok; lines:", len(ddl.splitlines()))
|
||||
print("exports ok:", [c.__name__ for c in (BatchWriter, MemorySink, TdengineSink)])
|
||||
Reference in New Issue
Block a user