Contact: fumanchu@aminus.org

Log in as guest/geniusql to create tickets

Changeset 3

Show
Ignore:
Timestamp:
02/12/07 02:43:10
Author:
fumanchu
Message:

More implementations of _grab_new_ids.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/geniusql/providers/mysql.py

    r2 r3  
    465465        return res.fetch_row(0, 0), res.describe() 
    466466     
     467    def _grab_new_ids(self, table, idkeys, conn): 
     468        return {idkeys[0]: conn.insert_id()} 
     469     
    467470    def create_database(self): 
    468471        self.lock("Creating database. Transactions not allowed.") 
  • trunk/geniusql/providers/psycopg.py

    r2 r3  
    417417        return data, coldefs 
    418418     
     419    def _grab_new_ids(self, table, idkeys, conn): 
     420        newids = {} 
     421        for idkey in idkeys: 
     422            col = table[idkey] 
     423            seq = col.sequence_name 
     424            data, _ = self.fetch("SELECT last_value FROM %s;" % seq, conn) 
     425            newids[idkey] = data[0][0] 
     426        return newids 
     427     
    419428    def create_database(self): 
    420429        self.lock("Creating database. Transactions not allowed.") 
  • trunk/geniusql/providers/pypgsql.py

    r2 r3  
    383383        return data, columns 
    384384     
     385    def _grab_new_ids(self, table, idkeys, conn): 
     386        """Insert a row using the table's SERIAL field.""" 
     387        newids = {} 
     388        for idkey in idkeys: 
     389            col = table[idkey] 
     390            seq = col.sequence_name 
     391            data, _ = self.fetch("SELECT last_value FROM %s;" % seq, conn) 
     392            newids[idkey] = data[0][0] 
     393        return newids 
     394     
    385395    def create_database(self): 
    386396        self.lock("Creating database. Transactions not allowed.") 
     
    415425        c.finish() 
    416426        return v 
    417      
    418     def _grab_new_ids(self, table, idkeys, conn): 
    419         """Insert a row using the table's SERIAL field.""" 
    420         newids = {} 
    421         for idkey in idkeys: 
    422             col = table[idkey] 
    423             seq = col.sequence_name 
    424             data, _ = self.fetch("SELECT last_value FROM %s;" % seq, conn) 
    425             newids[idkey] = data[0][0] 
    426         return newids 
    427  
     427 
  • trunk/geniusql/providers/sqlite.py

    r2 r3  
    612612                         % column.sequence_name) 
    613613            column.sequence_name = None 
     614     
     615    def _grab_new_ids(self, table, idkeys, conn): 
     616        if _lastrowid_support: 
     617            new_id = conn.lastrowid 
     618        else: 
     619            new_id = conn.sqlite_last_insert_rowid() 
     620        return {idkeys[0]: new_id} 
    614621     
    615622    def col_def(self, column):