-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql_agent_cli.py
More file actions
43 lines (34 loc) · 1021 Bytes
/
sql_agent_cli.py
File metadata and controls
43 lines (34 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "PyMySQL[rsa]>=1.1.0",
# "psycopg[binary]>=3.2.0",
# "sqlglot>=26.0.0",
# ]
# ///
from __future__ import annotations
import importlib
import importlib.util
import sys
from pathlib import Path
def _bootstrap_src() -> None:
root = Path(__file__).resolve().parent
src = root / "src"
package_dir = src / "sql_agent"
spec = importlib.util.spec_from_file_location(
"sql_agent",
package_dir / "__init__.py",
submodule_search_locations=[str(package_dir)],
)
if spec is None or spec.loader is None:
raise RuntimeError(f"Unable to bootstrap package from {package_dir}")
module = importlib.util.module_from_spec(spec)
sys.modules["sql_agent"] = module
spec.loader.exec_module(module)
def main() -> int:
_bootstrap_src()
cli_main = importlib.import_module("sql_agent.cli").main
return cli_main()
if __name__ == "__main__":
raise SystemExit(main())