Changeset 3030


Ignore:
Timestamp:
Sep 20, 2010 1:27:46 AM (11 years ago)
Author:
wehart
Message:

Removing tab characters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/data/db_table.py

    r3029 r3030  
    5454        tmp = []
    5555        if self.options.query is None:
    56             if self.options.table is None:
    57                 raise IOError, "Must specify 'query' or 'table' option!"
     56            if self.options.table is None:
     57                raise IOError, "Must specify 'query' or 'table' option!"
    5858            self.options.query = '"SELECT * FROM %s"' % self.options.table
    59         if not self.options.table is None:
    60             for row in cursor.columns(table=self.options.table):
     59        if not self.options.table is None:
     60            for row in cursor.columns(table=self.options.table):
    6161                tmp.append(row.column_name)
    62             tmp=[tmp]
     62            tmp=[tmp]
     63        else:
     64            # TODO: extend this logic to create a header row for a SQL query
     65            pass
    6366        #print "DATA start",self.options.query
    6467        cursor.execute(self.options.query[1:-1])
    6568        for row in cursor:
    6669            #print "DATA",list(row)
    67             ttmp=[]
     70            ttmp=[]
    6871            for data in list(row):
    6972                if isinstance(data,Decimal):
     
    7376                else:
    7477                    ttmp.append(data)
    75             tmp.append(ttmp)
     78            tmp.append(ttmp)
    7679        #print 'FINAL',tmp
    7780        #
     
    121124
    122125        def connect(self, connection, options):
    123             if not options.driver is None:
     126            if not options.driver is None:
    124127                ctype = options.driver
    125             elif '.' in connection:
     128            elif '.' in connection:
    126129                ctype = connection.split('.')[-1]
    127130            connection = self.create_connection_string(ctype, connection, options)
    128             if ctype in ['xls','excel'] or '.xls' in connection:
    129                 return db_Table.connect(self, connection, options, {'autocommit':True})
    130             return db_Table.connect(self, connection, options)
    131        
     131            if ctype in ['xls','excel'] or '.xls' in connection:
     132                return db_Table.connect(self, connection, options, {'autocommit':True})
     133            return db_Table.connect(self, connection, options)
     134       
    132135        def create_connection_string(self, ctype, connection, options):
    133             if ctype in ['xls', 'excel']:
    134                 return "Driver={Microsoft Excel Driver (*.xls)}; Dbq=%s;" % connection
    135             if ctype in ['mdb', 'access']:
    136                 return "Driver={Microsoft Access Driver (*.mdb)}; Dbq=%s;" % connection
    137             return connection
    138                    
     136            if ctype in ['xls', 'excel']:
     137                return "Driver={Microsoft Excel Driver (*.xls)}; Dbq=%s;" % connection
     138            if ctype in ['mdb', 'access']:
     139                return "Driver={Microsoft Access Driver (*.mdb)}; Dbq=%s;" % connection
     140            return connection
     141                   
    139142except ImportError:
    140143    pass
Note: See TracChangeset for help on using the changeset viewer.