Add get_last_insert_id() to Database API
This commit is contained in:
parent
864e37ddc8
commit
d00031edf7
|
@ -272,6 +272,9 @@ class Database:
|
|||
else:
|
||||
return None
|
||||
|
||||
def get_last_insert_id(self):
|
||||
return self.fdb.getLastInsertId()
|
||||
|
||||
|
||||
#stores a stud/razz hand into the database
|
||||
def ring_stud(self, config, settings, db, cursor, base, category, site_hand_no, gametype_id, hand_start_time
|
||||
|
@ -304,8 +307,6 @@ class Database:
|
|||
,action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos):
|
||||
"""stores a holdem/omaha hand into the database"""
|
||||
|
||||
# print "DEBUG: import_options = ", import_options
|
||||
|
||||
t0 = time()
|
||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||
t1 = time()
|
||||
|
@ -315,6 +316,7 @@ class Database:
|
|||
hands_id = fpdb_simple.storeHands(self.backend, db, cursor, site_hand_no, gametype_id
|
||||
,hand_start_time, names, tableName, maxSeats,
|
||||
hudImportData, board_values, board_suits)
|
||||
#TEMPORARY CALL! - Just until all functions are migrated
|
||||
t3 = time()
|
||||
hands_players_ids = fpdb_simple.store_hands_players_holdem_omaha(
|
||||
self.backend, db, cursor, category, hands_id, player_ids, start_cashes
|
||||
|
|
|
@ -596,7 +596,35 @@ class fpdb_db:
|
|||
+ "database (including fpdb) and try again (%s)." \
|
||||
% ( str(sys.exc_value).rstrip('\n'), )
|
||||
return(1)
|
||||
return(0)
|
||||
return(0)
|
||||
|
||||
def getLastInsertId(self):
|
||||
if self.backend == self.MYSQL_INNODB:
|
||||
ret = self.db.insert_id()
|
||||
if ret < 1 or ret > 999999999:
|
||||
print "getLastInsertId(): problem fetching insert_id? ret=", ret
|
||||
ret = -1
|
||||
elif self.backend == self.PGSQL:
|
||||
# some options:
|
||||
# currval(hands_id_seq) - use name of implicit seq here
|
||||
# lastval() - still needs sequences set up?
|
||||
# insert ... returning is useful syntax (but postgres specific?)
|
||||
# see rules (fancy trigger type things)
|
||||
self.cursor.execute ("SELECT lastval()")
|
||||
row = self.cursor.fetchone()
|
||||
if not row:
|
||||
print "getLastInsertId(%s): problem fetching lastval? row=" % seq, row
|
||||
ret = -1
|
||||
else:
|
||||
ret = row[0]
|
||||
elif self.backend == self.SQLITE:
|
||||
# don't know how to do this in sqlite
|
||||
print "getLastInsertId(): not coded for sqlite yet"
|
||||
ret = -1
|
||||
else:
|
||||
print "getLastInsertId(): unknown backend ", self.backend
|
||||
ret = -1
|
||||
return ret
|
||||
|
||||
def storeHand(self, p):
|
||||
#stores into table hands:
|
||||
|
|
Loading…
Reference in New Issue
Block a user