vortex-cli 4.14.1__tar.gz → 4.15.0__tar.gz

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 (41) hide show
  1. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/PKG-INFO +1 -1
  2. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/setup.cfg +1 -1
  3. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/cli.py +6 -2
  4. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/db.py +31 -5
  5. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex_cli.egg-info/PKG-INFO +1 -1
  6. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/LICENSE +0 -0
  7. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/README.md +0 -0
  8. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/setup.py +0 -0
  9. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/__init__.py +0 -0
  10. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/__main__.py +0 -0
  11. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/colour.py +0 -0
  12. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/__init__.py +0 -0
  13. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/clean.py +0 -0
  14. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/clone.py +0 -0
  15. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/code.py +0 -0
  16. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/config.py +0 -0
  17. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/copy.py +0 -0
  18. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/delete.py +0 -0
  19. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/docs.py +0 -0
  20. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/execute.py +0 -0
  21. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/find.py +0 -0
  22. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/grep.py +0 -0
  23. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/list.py +0 -0
  24. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/log.py +0 -0
  25. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/new.py +0 -0
  26. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/commands/watch.py +0 -0
  27. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/constants.py +0 -0
  28. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/docs/Blackbook.pdf +0 -0
  29. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/lib/puakma.jar +0 -0
  30. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/logging.py +0 -0
  31. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/main.py +0 -0
  32. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/models.py +0 -0
  33. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/soap.py +0 -0
  34. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/spinner.py +0 -0
  35. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/util.py +0 -0
  36. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex/workspace.py +0 -0
  37. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex_cli.egg-info/SOURCES.txt +0 -0
  38. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex_cli.egg-info/dependency_links.txt +0 -0
  39. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex_cli.egg-info/entry_points.txt +0 -0
  40. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex_cli.egg-info/requires.txt +0 -0
  41. {vortex_cli-4.14.1 → vortex_cli-4.15.0}/vortex_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vortex_cli
3
- Version: 4.14.1
3
+ Version: 4.15.0
4
4
  Home-page: https://github.com/jordanamos/vortex-cli
5
5
  Author: Jordan Amos
6
6
  Author-email: jordan.amos@gmail.com
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = vortex_cli
3
- version = 4.14.1
3
+ version = 4.15.0
4
4
  long_description = file: README.md
5
5
  long_description_content_type = text/markdown
6
6
  url = https://github.com/jordanamos/vortex-cli
@@ -536,9 +536,13 @@ def add_db_parser(command_parser: _SubParsersAction[ArgumentParser]) -> Argument
536
536
  db_mutex = db_parser.add_mutually_exclusive_group(required=True)
537
537
  db_mutex.add_argument(
538
538
  "--sql",
539
+ type=str,
540
+ nargs="?",
541
+ const="",
539
542
  help=(
540
- "Execute a given SQL query. "
541
- "Requires <database> to be a database connection id (int)."
543
+ "The SQL query to execute. "
544
+ "Requires <database> to be a database connection id (int). "
545
+ "Interactively prompts for the sql if the value is empty (Non Windows)."
542
546
  ),
543
547
  )
544
548
  db_mutex.add_argument(
@@ -1,6 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import logging
4
+ import os
5
+ import subprocess
6
+ import sys
7
+ import tempfile
4
8
  from typing import Any
5
9
 
6
10
  import tabulate
@@ -9,7 +13,6 @@ from vortex.models import DatabaseConnection
9
13
  from vortex.models import PuakmaServer
10
14
  from vortex.workspace import Workspace
11
15
 
12
-
13
16
  logger = logging.getLogger("vortex")
14
17
 
15
18
  GET_SCHEMA_SQL = """\
@@ -90,6 +93,8 @@ def _output_result(
90
93
  list_tables: bool = False,
91
94
  ) -> int:
92
95
  with server:
96
+ logger.debug("Executing query")
97
+ logger.debug(sql)
93
98
  result = tuple(server.database_designer.execute_query(conn_id, sql, update))
94
99
  if schema_table and not result:
95
100
  logger.error(f"Table '{schema_table}' not found in database '{db_name}'")
@@ -123,6 +128,21 @@ def _is_connection_cloned(workspace: Workspace, conn_id: int) -> bool:
123
128
  return any(conn.id == conn_id for conn in conns)
124
129
 
125
130
 
131
+ def _read_from_editor() -> str:
132
+ fd, tmp_sql_file = tempfile.mkstemp(suffix=".sql")
133
+ os.close(fd)
134
+ try:
135
+ subprocess.call(["nano", tmp_sql_file])
136
+ with open(tmp_sql_file) as f:
137
+ sql_query = f.read().strip()
138
+ except Exception:
139
+ os.remove(tmp_sql_file)
140
+ raise
141
+ else:
142
+ os.remove(tmp_sql_file)
143
+ return sql_query
144
+
145
+
126
146
  def db(
127
147
  workspace: Workspace,
128
148
  server: PuakmaServer,
@@ -134,7 +154,12 @@ def db(
134
154
  list_tables: bool = False,
135
155
  truncate_cols: bool = False,
136
156
  ) -> int:
137
- if sql:
157
+ if sql is not None:
158
+ if sql.strip() == "":
159
+ if sys.platform == "win32":
160
+ sql = None
161
+ else:
162
+ sql = _read_from_editor()
138
163
  db_name = None
139
164
  conn_id = int(database)
140
165
  # If we're modifying a database, lets check that its locally
@@ -142,7 +167,7 @@ def db(
142
167
  if update and not _is_connection_cloned(workspace, conn_id):
143
168
  logger.error(f"No cloned applications with DB Connection ID '{conn_id}'")
144
169
  return 1
145
- if not update:
170
+ if sql and not update:
146
171
  sql = sql + f" LIMIT {limit_n_results}"
147
172
  else:
148
173
  db_name = str(database).lower()
@@ -154,8 +179,9 @@ def db(
154
179
  elif list_tables:
155
180
  sql = LIST_TABLES_SQL % db_name
156
181
 
157
- if sql is None:
158
- raise ValueError("No Query to execute.")
182
+ if not sql:
183
+ logger.error("No Query to execute.")
184
+ return 1
159
185
 
160
186
  return _output_result(
161
187
  server, conn_id, sql, update, truncate_cols, db_name, schema_table, list_tables
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vortex_cli
3
- Version: 4.14.1
3
+ Version: 4.15.0
4
4
  Home-page: https://github.com/jordanamos/vortex-cli
5
5
  Author: Jordan Amos
6
6
  Author-email: jordan.amos@gmail.com
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes