Skip to content

Commit 2abc225

Browse files
committed
feat: take in multiple queries to execute in sequence in the smoke test script
1 parent 9dfeab8 commit 2abc225

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

tests/smoke.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
parser.add_argument(
3939
"--wide", help="Enable wide output", action="store_const", const=80, default=30
4040
)
41-
parser.add_argument("sql", help="SQL query to execute")
41+
parser.add_argument("sql", nargs="+", help="SQL query to execute")
4242
args = parser.parse_args()
4343

4444
logging.basicConfig(
@@ -77,16 +77,18 @@
7777
wait_timeout=900,
7878
)
7979

80-
with conn_func() as conn:
81-
cursor = conn.cursor()
82-
cursor.execute(args.sql)
83-
results: pandas.DataFrame = cursor.fetchall()
80+
def render(results: pandas.DataFrame):
81+
table = Table()
82+
table.add_column("#")
83+
for column in results.columns:
84+
table.add_column(column, max_width=args.wide, no_wrap=True)
85+
for row in results.itertuples(name=None):
86+
r = [str(x) for x in row]
87+
table.add_row(*r)
88+
Console().print(table)
8489

85-
table = Table()
86-
table.add_column("#")
87-
for column in results.columns:
88-
table.add_column(column, max_width=args.wide, no_wrap=True)
89-
for row in results.itertuples(name=None):
90-
r = [str(x) for x in row]
91-
table.add_row(*r)
92-
Console().print(table)
90+
with conn_func() as conn:
91+
for sql in args.sql:
92+
with conn.cursor() as cursor:
93+
cursor.execute(sql)
94+
render(cursor.fetchall())

0 commit comments

Comments
 (0)