sqlingpl 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlingpl/__init__.py +63 -0
- sqlingpl/__main__.py +32 -0
- sqlingpl/adapters.py +2720 -0
- sqlingpl/alter_modify.py +365 -0
- sqlingpl/application.py +495 -0
- sqlingpl/ast_nodes.py +972 -0
- sqlingpl/audit.py +445 -0
- sqlingpl/builtins.py +1145 -0
- sqlingpl/catalog.py +1175 -0
- sqlingpl/check.py +698 -0
- sqlingpl/cli.py +722 -0
- sqlingpl/conditional.py +481 -0
- sqlingpl/connect_by.py +1165 -0
- sqlingpl/cross_views.py +119 -0
- sqlingpl/csv_loader.py +886 -0
- sqlingpl/cursors.py +287 -0
- sqlingpl/db_links.py +132 -0
- sqlingpl/ddl_columns.py +139 -0
- sqlingpl/ddl_order.py +148 -0
- sqlingpl/describe.py +170 -0
- sqlingpl/dictionary.py +1688 -0
- sqlingpl/errors.py +297 -0
- sqlingpl/formats.py +663 -0
- sqlingpl/interpreter.py +9557 -0
- sqlingpl/json_types.py +306 -0
- sqlingpl/lexer.py +434 -0
- sqlingpl/loader.py +654 -0
- sqlingpl/mariadb.py +2243 -0
- sqlingpl/merge.py +460 -0
- sqlingpl/modern_sql.py +1002 -0
- sqlingpl/multitable.py +313 -0
- sqlingpl/native/__init__.py +165 -0
- sqlingpl/native/mariadb.py +697 -0
- sqlingpl/native/postgres.py +487 -0
- sqlingpl/native/translate.py +770 -0
- sqlingpl/object_methods.py +162 -0
- sqlingpl/object_types.py +691 -0
- sqlingpl/oracle.py +677 -0
- sqlingpl/oracle_dump.py +1212 -0
- sqlingpl/oracle_text.py +595 -0
- sqlingpl/outer_join.py +792 -0
- sqlingpl/owa_packages.sql +1096 -0
- sqlingpl/owa_toolkit.py +410 -0
- sqlingpl/packages.py +4975 -0
- sqlingpl/parser.py +3221 -0
- sqlingpl/pglite_bridge.py +429 -0
- sqlingpl/plsql_library.py +241 -0
- sqlingpl/rename.py +590 -0
- sqlingpl/renderers.py +250 -0
- sqlingpl/repl_support.py +204 -0
- sqlingpl/report/__init__.py +61 -0
- sqlingpl/report/document.py +365 -0
- sqlingpl/report/spec.py +457 -0
- sqlingpl/report/text.py +362 -0
- sqlingpl/schema_check.py +185 -0
- sqlingpl/scope.py +185 -0
- sqlingpl/script_stream.py +144 -0
- sqlingpl/sequences.py +423 -0
- sqlingpl/settings.py +316 -0
- sqlingpl/sql_calls.py +598 -0
- sqlingpl/sql_engine.py +11200 -0
- sqlingpl/sql_functions.py +2146 -0
- sqlingpl/sqlldr.py +183 -0
- sqlingpl/subset.py +683 -0
- sqlingpl/substitution.py +573 -0
- sqlingpl/translate_script.py +185 -0
- sqlingpl/trigger_dispatch.py +725 -0
- sqlingpl/triggers.py +327 -0
- sqlingpl/types.py +847 -0
- sqlingpl/view_dml.py +497 -0
- sqlingpl/web_toolkit.py +974 -0
- sqlingpl-0.1.0.dist-info/METADATA +2119 -0
- sqlingpl-0.1.0.dist-info/RECORD +77 -0
- sqlingpl-0.1.0.dist-info/WHEEL +5 -0
- sqlingpl-0.1.0.dist-info/entry_points.txt +4 -0
- sqlingpl-0.1.0.dist-info/licenses/LICENSE +21 -0
- sqlingpl-0.1.0.dist-info/top_level.txt +1 -0
sqlingpl/__init__.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""sqlingpl -- a PL/SQL interpreter over SQLite and DuckDB.
|
|
2
|
+
|
|
3
|
+
Two ways in. As a command line tool::
|
|
4
|
+
|
|
5
|
+
python -m sqlingpl script.sql # or just "sqlingpl" once installed
|
|
6
|
+
|
|
7
|
+
As a library embedded in another project::
|
|
8
|
+
|
|
9
|
+
from sqlingpl import Interpreter
|
|
10
|
+
|
|
11
|
+
with Interpreter(database="app.db", capture_output=True) as db:
|
|
12
|
+
db.run_source(open("procs.sql").read())
|
|
13
|
+
total = db.call("order_total", 1234)
|
|
14
|
+
for line in db.take_output():
|
|
15
|
+
log.info(line)
|
|
16
|
+
|
|
17
|
+
``Interpreter`` can also adopt a connection the host application already
|
|
18
|
+
owns, so both sides share one transaction::
|
|
19
|
+
|
|
20
|
+
import sqlite3
|
|
21
|
+
conn = sqlite3.connect("app.db")
|
|
22
|
+
db = Interpreter(connection=conn) # conn is never closed by sqlingpl
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from .csv_loader import (
|
|
26
|
+
load_csv,
|
|
27
|
+
load_from_control_text,
|
|
28
|
+
emit_sql_from_control,
|
|
29
|
+
emit_sql_from_control_text,
|
|
30
|
+
emit_create_table,
|
|
31
|
+
emit_create_plus_inserts,
|
|
32
|
+
emit_external_table_ddl,
|
|
33
|
+
emit_control_file,
|
|
34
|
+
preview as preview_csv,
|
|
35
|
+
parse_control,
|
|
36
|
+
)
|
|
37
|
+
from .errors import PlsqlError, PlsqlSyntaxError
|
|
38
|
+
from .interpreter import Interpreter
|
|
39
|
+
from .parser import parse
|
|
40
|
+
from .sqlldr import load_from_control
|
|
41
|
+
from .types import to_display, to_plsql
|
|
42
|
+
|
|
43
|
+
__version__ = "0.1.0"
|
|
44
|
+
__all__ = [
|
|
45
|
+
"Interpreter", "parse", "run",
|
|
46
|
+
"PlsqlError", "PlsqlSyntaxError",
|
|
47
|
+
"to_plsql", "to_display",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def run(source, database=":memory:", db_engine="sqlite", output_enabled=True,
|
|
52
|
+
connection=None, capture_output=False):
|
|
53
|
+
"""Run PL/SQL source and return the interpreter, for one-shot use.
|
|
54
|
+
|
|
55
|
+
The interpreter is returned rather than closed so the caller can read
|
|
56
|
+
variables, call subprograms, or collect output afterwards.
|
|
57
|
+
"""
|
|
58
|
+
interpreter = Interpreter(database=database, db_engine=db_engine,
|
|
59
|
+
output_enabled=output_enabled,
|
|
60
|
+
connection=connection,
|
|
61
|
+
capture_output=capture_output)
|
|
62
|
+
interpreter.run_source(source)
|
|
63
|
+
return interpreter
|
sqlingpl/__main__.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Entry point for running the package directly.
|
|
2
|
+
|
|
3
|
+
This has to cope with two different invocations that look alike but are not:
|
|
4
|
+
|
|
5
|
+
python -m sqlingpl imports sqlingpl.__main__ *as part of the package*,
|
|
6
|
+
so ``__package__`` is "sqlingpl" and a relative
|
|
7
|
+
import works.
|
|
8
|
+
|
|
9
|
+
python sqlingpl treats the directory as a script, runs this file
|
|
10
|
+
python sqlingpl/__main__.py as top-level "__main__" with no package at all,
|
|
11
|
+
putting *this* directory on sys.path rather than
|
|
12
|
+
the project root. A relative import then fails
|
|
13
|
+
with "attempted relative import with no known
|
|
14
|
+
parent package".
|
|
15
|
+
|
|
16
|
+
The second form is the one people reach for out of habit, so both are
|
|
17
|
+
supported: when there is no package context, put the project root on sys.path
|
|
18
|
+
and import absolutely.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import os
|
|
22
|
+
import sys
|
|
23
|
+
|
|
24
|
+
if __package__ in (None, ""):
|
|
25
|
+
sys.path.insert(
|
|
26
|
+
0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
27
|
+
from sqlingpl.cli import main
|
|
28
|
+
else:
|
|
29
|
+
from .cli import main
|
|
30
|
+
|
|
31
|
+
if __name__ == "__main__":
|
|
32
|
+
sys.exit(main())
|