@@ -34,11 +34,11 @@ def setup_query(self):
3434                )
3535                self .select .append (selection )
3636
37-     def  execute_sql (self , csv_path = None ):
37+     def  execute_sql (self , csv_path_or_obj = None ):
3838        """ 
3939        Run the COPY TO query. 
4040        """ 
41-         logger .debug ("Copying data to {}" .format (csv_path ))
41+         logger .debug ("Copying data to {}" .format (csv_path_or_obj ))
4242
4343        # adapt SELECT query parameters to SQL syntax 
4444        params  =  self .as_sql ()[1 ]
@@ -67,12 +67,12 @@ def execute_sql(self, csv_path=None):
6767            logger .debug (copy_to_sql )
6868
6969            # 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 )
7272                return 
7373            # 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 :
7676                    c .cursor .copy_expert (copy_to_sql , stdout )
7777                    return 
7878            # If there's no csv_path, return the output as a string. 
0 commit comments