1
1
#!/usr/bin/env python
2
-
3
2
import os .path
4
3
import sys
5
4
6
5
import agate
7
6
import agatesql # noqa: F401
8
7
from sqlalchemy import create_engine , dialects
9
8
10
- from csvkit .cli import CSVKitUtility , isatty
9
+ from csvkit .cli import CSVKitUtility , isatty , parse_list
11
10
12
11
try :
13
12
import importlib_metadata
@@ -33,6 +32,10 @@ def add_arguments(self):
33
32
self .argparser .add_argument (
34
33
'--db' , dest = 'connection_string' ,
35
34
help = 'If present, a SQLAlchemy connection string to use to directly execute generated SQL on a database.' )
35
+ self .argparser .add_argument (
36
+ '--engine-option' , dest = 'engine_option' , nargs = 2 , action = 'append' , default = [],
37
+ help = "A keyword argument to SQLAlchemy's create_engine(), as a space-separated pair. "
38
+ "This option can be specified multiple times. For example: thick_mode True" )
36
39
self .argparser .add_argument (
37
40
'--query' , dest = 'queries' , action = 'append' ,
38
41
help = 'Execute one or more SQL queries delimited by ";" and output the result of the last query as CSV. '
@@ -137,7 +140,7 @@ def main(self):
137
140
# Establish database validity before reading CSV files
138
141
if self .args .connection_string :
139
142
try :
140
- engine = create_engine (self .args .connection_string )
143
+ engine = create_engine (self .args .connection_string , ** parse_list ( self . args . engine_option ) )
141
144
except ImportError as e :
142
145
raise ImportError (
143
146
"You don't appear to have the necessary database backend installed for connection string you're "
0 commit comments