Read SQL from file or stdin.
(args: argparse.Namespace)
| 187 | |
| 188 | |
| 189 | def read_sql(args: argparse.Namespace) -> str: |
| 190 | """Read SQL from file or stdin.""" |
| 191 | if args.sql_file: |
| 192 | sql_path = Path(args.sql_file) |
| 193 | if not sql_path.exists(): |
| 194 | print(f"Error: SQL file not found: {args.sql_file}", file=sys.stderr) |
| 195 | sys.exit(1) |
| 196 | with open(sql_path, "r") as f: |
| 197 | return f.read() |
| 198 | else: |
| 199 | # Read from stdin |
| 200 | return sys.stdin.read() |
| 201 | |
| 202 | |
| 203 | def execute_sql(conn, sql: str, db_type: str) -> None: |