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.
Files changed (77) hide show
  1. sqlingpl/__init__.py +63 -0
  2. sqlingpl/__main__.py +32 -0
  3. sqlingpl/adapters.py +2720 -0
  4. sqlingpl/alter_modify.py +365 -0
  5. sqlingpl/application.py +495 -0
  6. sqlingpl/ast_nodes.py +972 -0
  7. sqlingpl/audit.py +445 -0
  8. sqlingpl/builtins.py +1145 -0
  9. sqlingpl/catalog.py +1175 -0
  10. sqlingpl/check.py +698 -0
  11. sqlingpl/cli.py +722 -0
  12. sqlingpl/conditional.py +481 -0
  13. sqlingpl/connect_by.py +1165 -0
  14. sqlingpl/cross_views.py +119 -0
  15. sqlingpl/csv_loader.py +886 -0
  16. sqlingpl/cursors.py +287 -0
  17. sqlingpl/db_links.py +132 -0
  18. sqlingpl/ddl_columns.py +139 -0
  19. sqlingpl/ddl_order.py +148 -0
  20. sqlingpl/describe.py +170 -0
  21. sqlingpl/dictionary.py +1688 -0
  22. sqlingpl/errors.py +297 -0
  23. sqlingpl/formats.py +663 -0
  24. sqlingpl/interpreter.py +9557 -0
  25. sqlingpl/json_types.py +306 -0
  26. sqlingpl/lexer.py +434 -0
  27. sqlingpl/loader.py +654 -0
  28. sqlingpl/mariadb.py +2243 -0
  29. sqlingpl/merge.py +460 -0
  30. sqlingpl/modern_sql.py +1002 -0
  31. sqlingpl/multitable.py +313 -0
  32. sqlingpl/native/__init__.py +165 -0
  33. sqlingpl/native/mariadb.py +697 -0
  34. sqlingpl/native/postgres.py +487 -0
  35. sqlingpl/native/translate.py +770 -0
  36. sqlingpl/object_methods.py +162 -0
  37. sqlingpl/object_types.py +691 -0
  38. sqlingpl/oracle.py +677 -0
  39. sqlingpl/oracle_dump.py +1212 -0
  40. sqlingpl/oracle_text.py +595 -0
  41. sqlingpl/outer_join.py +792 -0
  42. sqlingpl/owa_packages.sql +1096 -0
  43. sqlingpl/owa_toolkit.py +410 -0
  44. sqlingpl/packages.py +4975 -0
  45. sqlingpl/parser.py +3221 -0
  46. sqlingpl/pglite_bridge.py +429 -0
  47. sqlingpl/plsql_library.py +241 -0
  48. sqlingpl/rename.py +590 -0
  49. sqlingpl/renderers.py +250 -0
  50. sqlingpl/repl_support.py +204 -0
  51. sqlingpl/report/__init__.py +61 -0
  52. sqlingpl/report/document.py +365 -0
  53. sqlingpl/report/spec.py +457 -0
  54. sqlingpl/report/text.py +362 -0
  55. sqlingpl/schema_check.py +185 -0
  56. sqlingpl/scope.py +185 -0
  57. sqlingpl/script_stream.py +144 -0
  58. sqlingpl/sequences.py +423 -0
  59. sqlingpl/settings.py +316 -0
  60. sqlingpl/sql_calls.py +598 -0
  61. sqlingpl/sql_engine.py +11200 -0
  62. sqlingpl/sql_functions.py +2146 -0
  63. sqlingpl/sqlldr.py +183 -0
  64. sqlingpl/subset.py +683 -0
  65. sqlingpl/substitution.py +573 -0
  66. sqlingpl/translate_script.py +185 -0
  67. sqlingpl/trigger_dispatch.py +725 -0
  68. sqlingpl/triggers.py +327 -0
  69. sqlingpl/types.py +847 -0
  70. sqlingpl/view_dml.py +497 -0
  71. sqlingpl/web_toolkit.py +974 -0
  72. sqlingpl-0.1.0.dist-info/METADATA +2119 -0
  73. sqlingpl-0.1.0.dist-info/RECORD +77 -0
  74. sqlingpl-0.1.0.dist-info/WHEEL +5 -0
  75. sqlingpl-0.1.0.dist-info/entry_points.txt +4 -0
  76. sqlingpl-0.1.0.dist-info/licenses/LICENSE +21 -0
  77. 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())