@@ -34,11 +34,11 @@ def setup_query(self):
34
34
)
35
35
self .select .append (selection )
36
36
37
- def execute_sql (self , csv_path = None ):
37
+ def execute_sql (self , csv_path_or_obj = None ):
38
38
"""
39
39
Run the COPY TO query.
40
40
"""
41
- logger .debug ("Copying data to {}" .format (csv_path ))
41
+ logger .debug ("Copying data to {}" .format (csv_path_or_obj ))
42
42
43
43
# adapt SELECT query parameters to SQL syntax
44
44
params = self .as_sql ()[1 ]
@@ -67,12 +67,12 @@ def execute_sql(self, csv_path=None):
67
67
logger .debug (copy_to_sql )
68
68
69
69
# If a file-like object was provided, write it out there.
70
- if hasattr (csv_path , 'write' ):
71
- c .cursor .copy_expert (copy_to_sql , csv_path )
70
+ if hasattr (csv_path_or_obj , 'write' ):
71
+ c .cursor .copy_expert (copy_to_sql , csv_path_or_obj )
72
72
return
73
73
# If a file path was provided, write it out there.
74
- elif csv_path :
75
- with open (csv_path , 'wb' ) as stdout :
74
+ elif csv_path_or_obj :
75
+ with open (csv_path_or_obj , 'wb' ) as stdout :
76
76
c .cursor .copy_expert (copy_to_sql , stdout )
77
77
return
78
78
# If there's no csv_path, return the output as a string.
0 commit comments