File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 11# A simple smoke test for the DB driver.
22
33import argparse
4+ import concurrent .futures
45import functools
56import logging
67import sys
1112
1213from wherobots .db import connect , connect_direct
1314from wherobots .db .constants import DEFAULT_ENDPOINT
15+ from wherobots .db .connection import Connection
1416from wherobots .db .region import Region
1517from wherobots .db .runtime import Runtime
1618
@@ -85,8 +87,13 @@ def render(results: pandas.DataFrame):
8587 table .add_row (* r )
8688 Console ().print (table )
8789
90+ def execute (conn : Connection , sql : str ) -> pandas .DataFrame :
91+ with conn .cursor () as cursor :
92+ cursor .execute (sql )
93+ return cursor .fetchall ()
94+
8895 with conn_func () as conn :
89- for sql in args . sql :
90- with conn . cursor () as cursor :
91- cursor . execute ( sql )
92- render (cursor . fetchall ())
96+ with concurrent . futures . ThreadPoolExecutor () as pool :
97+ futures = [ pool . submit ( execute , conn , s ) for s in args . sql ]
98+ for future in concurrent . futures . as_completed ( futures ):
99+ render (future . result ())
You can’t perform that action at this time.
0 commit comments