Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

I think I've seen this ORM somewhere before...

Changeset 151

Show
Ignore:
Timestamp:
02/01/06 00:11:58
Author:
fumanchu
Message:

Removed the CreateIfMissing? option; this should now be performed with a schema instead.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/storage/db.py

    r150 r151  
    781781        if adapter: self.fromAdapter = adapter 
    782782         
    783         self.CreateIfMissing = bool(allOptions.get(u'Create If Missing', 'True')) 
    784783        self.pool_size = int(allOptions.get(u'Pool Size', '10')) 
    785784         
     
    847846    def _get_conn(self): 
    848847        # Override this with the connection call for your DB. Example: 
    849         # try: 
    850         #     conn = libpq.PQconnectdb(self.connstring) 
    851         # except Exception, x: 
    852         #     if self.CreateIfMissing: 
    853         #         self.create_database() 
    854         #         conn = libpq.PQconnectdb(self.connstring) 
    855         #     else: 
    856         #         raise 
    857         # return conn 
     848        #     return libpq.PQconnectdb(self.connstring) 
    858849        raise NotImplementedError 
    859850     
    860851    def connection(self): 
    861852        if not self.threaded: 
     853            # Place a single 'conn' entry in self.refs. 
    862854            try: 
    863855                return self.refs['conn'] 
     
    898890     
    899891    def release(self, ref): 
    900         conn = self.refs[ref] 
    901         del self.refs[ref] 
     892        # This method should only be called if self.threaded is True 
     893        conn = self.refs.pop(ref) 
    902894         
    903895        if self.pool is not None: 
  • trunk/storage/storeado.py

    r150 r151  
    332332    def _get_conn(self): 
    333333        conn = win32com.client.Dispatch(r'ADODB.Connection') 
    334         try: 
    335             conn.Open(self.connstring) 
    336             return conn 
    337         except pywintypes.com_error, x: 
    338             if x.args[2][5] == -2147467259: 
    339                 msg = x.args[2][2] 
    340                 if ( 
    341                     # SQL Server: "Cannot open database requested in login 
    342                     # 'dejavu_test'. Login fails." 
    343                     msg.startswith("Cannot open database") or 
    344                     # MSAccess: "Could not find file 
    345                     # 'C:\Python23\Lib\site-packages\dejavu\storage\zoo.mdb'." 
    346                     msg.startswith("Could not find file")): 
    347                     if self.CreateIfMissing: 
    348                         self.create_database() 
    349                         conn.Open(self.connstring) 
    350                         return conn 
    351             raise 
     334        conn.Open(self.connstring) 
     335        return conn 
    352336     
    353337    def execute(self, query, conn=None): 
  • trunk/storage/storemysql.py

    r150 r151  
    161161            if x.args[0] == 1040:   # Too many connections 
    162162                raise db.OutOfConnectionsError 
    163             elif x.args[0] == 1049 and self.CreateIfMissing: 
    164                 self.create_database() 
    165                 conn = _mysql.connect(**self.connargs) 
    166             else: 
    167                 raise 
     163            raise 
    168164        return conn 
    169165     
  • trunk/storage/storepypgsql.py

    r150 r151  
    6666            return libpq.PQconnectdb(self.connstring) 
    6767        except libpq.DatabaseError, x: 
    68             msg = x.args[0] 
    69             if msg.endswith('does not exist\n'): 
    70                 if self.CreateIfMissing: 
    71                     self.create_database() 
    72                     return libpq.PQconnectdb(self.connstring) 
    73             elif msg.startswith('could not connect'): 
     68            if x.args[0].startswith('could not connect'): 
    7469                raise db.OutOfConnectionsError 
    75             raise x 
     70            raise 
    7671     
    7772    def _template_conn(self):