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 1
1
# A simple smoke test for the DB driver.
2
2
3
3
import argparse
4
+ import concurrent .futures
4
5
import functools
5
6
import logging
6
7
import sys
11
12
12
13
from wherobots .db import connect , connect_direct
13
14
from wherobots .db .constants import DEFAULT_ENDPOINT
15
+ from wherobots .db .connection import Connection
14
16
from wherobots .db .region import Region
15
17
from wherobots .db .runtime import Runtime
16
18
@@ -85,8 +87,13 @@ def render(results: pandas.DataFrame):
85
87
table .add_row (* r )
86
88
Console ().print (table )
87
89
90
+ def execute (conn : Connection , sql : str ) -> pandas .DataFrame :
91
+ with conn .cursor () as cursor :
92
+ cursor .execute (sql )
93
+ return cursor .fetchall ()
94
+
88
95
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