sqlsaber 0.9.0__py3-none-any.whl → 0.10.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.

Potentially problematic release.


This version of sqlsaber might be problematic. Click here for more details.

sqlsaber/cli/commands.py CHANGED
@@ -51,9 +51,11 @@ def meta_handler(
51
51
  Query your database using natural language.
52
52
 
53
53
  Examples:
54
- saber # Start interactive mode
55
- saber "show me all users" # Run a single query with default database
56
- saber -d mydb "show me users" # Run a query with specific database
54
+ saber # Start interactive mode
55
+ saber "show me all users" # Run a single query with default database
56
+ saber -d mydb "show me users" # Run a query with specific database
57
+ echo "show me all users" | saber # Read query from stdin
58
+ cat query.txt | saber # Read query from file via stdin
57
59
  """
58
60
  # Store database in app context for commands to access
59
61
  app.meta["database"] = database
@@ -64,7 +66,7 @@ def query(
64
66
  query_text: Annotated[
65
67
  str | None,
66
68
  cyclopts.Parameter(
67
- help="SQL query in natural language (if not provided, starts interactive mode)",
69
+ help="SQL query in natural language (if not provided, reads from stdin or starts interactive mode)",
68
70
  ),
69
71
  ] = None,
70
72
  database: Annotated[
@@ -77,11 +79,28 @@ def query(
77
79
  ):
78
80
  """Run a query against the database or start interactive mode.
79
81
 
80
- When called without arguments, starts interactive mode.
82
+ When called without arguments:
83
+ - If stdin has data, reads query from stdin
84
+ - Otherwise, starts interactive mode
85
+
81
86
  When called with a query string, executes that query and exits.
87
+
88
+ Examples:
89
+ saber # Start interactive mode
90
+ saber "show me all users" # Run a single query
91
+ echo "show me all users" | saber # Read query from stdin
82
92
  """
83
93
 
84
94
  async def run_session():
95
+ # Check if query_text is None and stdin has data
96
+ actual_query = query_text
97
+ if query_text is None and not sys.stdin.isatty():
98
+ # Read from stdin
99
+ actual_query = sys.stdin.read().strip()
100
+ if not actual_query:
101
+ # If stdin was empty, fall back to interactive mode
102
+ actual_query = None
103
+
85
104
  # Get database configuration or handle direct CSV file
86
105
  if database:
87
106
  # Check if this is a direct CSV file path
@@ -119,13 +138,13 @@ def query(
119
138
  agent = AnthropicSQLAgent(db_conn, db_name)
120
139
 
121
140
  try:
122
- if query_text:
141
+ if actual_query:
123
142
  # Single query mode with streaming
124
143
  streaming_handler = StreamingQueryHandler(console)
125
144
  console.print(
126
145
  f"[bold blue]Connected to:[/bold blue] {db_name} {agent._get_database_type_name()}\n"
127
146
  )
128
- await streaming_handler.execute_streaming_query(query_text, agent)
147
+ await streaming_handler.execute_streaming_query(actual_query, agent)
129
148
  else:
130
149
  # Interactive mode
131
150
  session = InteractiveSession(console, agent)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlsaber
3
- Version: 0.9.0
3
+ Version: 0.10.0
4
4
  Summary: SQLSaber - Agentic SQL assistant like Claude Code
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -139,6 +139,13 @@ Execute a single natural language query:
139
139
  saber "show me all users created this month"
140
140
  ```
141
141
 
142
+ You can also pipe queries from stdin:
143
+
144
+ ```bash
145
+ echo "show me all users created this month" | saber
146
+ cat query.txt | saber
147
+ ```
148
+
142
149
  ### Database Selection
143
150
 
144
151
  Use a specific database connection:
@@ -7,7 +7,7 @@ sqlsaber/agents/mcp.py,sha256=FKtXgDrPZ2-xqUYCw2baI5JzrWekXaC5fjkYW1_Mg50,827
7
7
  sqlsaber/agents/streaming.py,sha256=LaSeMTlxuJFRArJVqDly5-_KgcePiCCKPKfMxfB4oGs,521
8
8
  sqlsaber/cli/__init__.py,sha256=qVSLVJLLJYzoC6aj6y9MFrzZvAwc4_OgxU9DlkQnZ4M,86
9
9
  sqlsaber/cli/auth.py,sha256=1yvawtS5NGj9dWMRZ8I5T6sqBiRqZpPsjEPrJSQBJAs,4979
10
- sqlsaber/cli/commands.py,sha256=ABmw9U6HwSJI61d9iK0X3nsFKLMqfcQGQEYE9ZoZHlw,5494
10
+ sqlsaber/cli/commands.py,sha256=84KpBtrcoprWVuQjlGuzR6D34Ep2fCf8G1pmxrThswE,6329
11
11
  sqlsaber/cli/completers.py,sha256=HsUPjaZweLSeYCWkAcgMl8FylQ1xjWBWYTEL_9F6xfU,6430
12
12
  sqlsaber/cli/database.py,sha256=tJ8rqGrafZpg3VgDmSiq7eZoPscoGAW3XLTYGoQw8LE,12910
13
13
  sqlsaber/cli/display.py,sha256=wC-xYmmD21XyAkpRdMW7Ch2Mn5SlM1X34pbpka2ZIX8,10083
@@ -39,8 +39,8 @@ sqlsaber/memory/storage.py,sha256=ne8szLlGj5NELheqLnI7zu21V8YS4rtpYGGC7tOmi-s,57
39
39
  sqlsaber/models/__init__.py,sha256=RJ7p3WtuSwwpFQ1Iw4_DHV2zzCtHqIzsjJzxv8kUjUE,287
40
40
  sqlsaber/models/events.py,sha256=89SXKb5GGpH01yTr2kPEBhzp9xv35RFIYuFdAZSIPoE,721
41
41
  sqlsaber/models/types.py,sha256=w-zk81V2dtveuteej36_o1fDK3So428j3P2rAejU62U,862
42
- sqlsaber-0.9.0.dist-info/METADATA,sha256=F2LyQDJS7tE1PfA2LhHJfjNU1qo35MbloSjvJyXgCs4,6023
43
- sqlsaber-0.9.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
44
- sqlsaber-0.9.0.dist-info/entry_points.txt,sha256=qEbOB7OffXPFgyJc7qEIJlMEX5RN9xdzLmWZa91zCQQ,162
45
- sqlsaber-0.9.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
46
- sqlsaber-0.9.0.dist-info/RECORD,,
42
+ sqlsaber-0.10.0.dist-info/METADATA,sha256=mnHp2BteZvCNwoG3mUW-ulbBFxvQa4i5JkCffUHCEhc,6150
43
+ sqlsaber-0.10.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
44
+ sqlsaber-0.10.0.dist-info/entry_points.txt,sha256=qEbOB7OffXPFgyJc7qEIJlMEX5RN9xdzLmWZa91zCQQ,162
45
+ sqlsaber-0.10.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
46
+ sqlsaber-0.10.0.dist-info/RECORD,,