sql and cursor execute bugfixes to make it work with postgres
This commit is contained in:
		
							parent
							
								
									a466201285
								
							
						
					
					
						commit
						2c991ad2d0
					
				|  | @ -120,7 +120,7 @@ class Database: | |||
|         """Get and return the cards for each player in the hand.""" | ||||
|         cards = {} # dict of cards, the key is the seat number example: {1: 'AcQd9hTs5d'} | ||||
|         c = self.connection.cursor() | ||||
|         c.execute(self.sql.query['get_cards'], hand) | ||||
|         c.execute(self.sql.query['get_cards'], [hand]) | ||||
|         colnames = [desc[0] for desc in c.description] | ||||
|         for row in c.fetchall(): | ||||
|             s_dict = {} | ||||
|  | @ -133,7 +133,7 @@ class Database: | |||
|         """Get and return the community cards for the specified hand.""" | ||||
|         cards = {} | ||||
|         c = self.connection.cursor() | ||||
|         c.execute(self.sql.query['get_common_cards'], hand) | ||||
|         c.execute(self.sql.query['get_common_cards'], [hand]) | ||||
|         colnames = [desc[0] for desc in c.description] | ||||
|         for row in c.fetchall(): | ||||
|             s_dict = {} | ||||
|  |  | |||
|  | @ -173,6 +173,8 @@ class Sql: | |||
| 
 | ||||
|             self.query['get_stats_from_hand'] = """ | ||||
|                     SELECT HudCache.playerId             AS player_id,  | ||||
|                         HandsPlayers.seatNo              AS seat, | ||||
|                         Players.name                     AS screen_name, | ||||
|                         seatNo                           AS seat, | ||||
|                         name                             AS screen_name, | ||||
|                         sum(HDs)                         AS n, | ||||
|  | @ -237,7 +239,7 @@ class Sql: | |||
|                                                  AND HudCache.gametypeId+0 = Hands.gametypeId+0) | ||||
|                          INNER JOIN Players ON (Players.id = HandsPlayers.PlayerId+0) | ||||
|                     WHERE Hands.id = %s | ||||
|                     GROUP BY HudCache.PlayerId | ||||
|                     GROUP BY HudCache.PlayerId, HandsPlayers.seatNo, Players.name | ||||
|                 """ | ||||
| 
 | ||||
| #    same as above except stats are aggregated for all blind/limit levels | ||||
|  |  | |||
|  | @ -1411,7 +1411,7 @@ def recognisePlayerIDs(cursor, names, site_id): | |||
|     if len(ids) != len(names): | ||||
|         notfound = [n for n in names if n not in ids] # make list of names not in database | ||||
|         if notfound: # insert them into database | ||||
|             cursor.executemany("INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")", (notfound)) | ||||
|             cursor.executemany("INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")", [[n] for n in notfound]) | ||||
|             q2 = "SELECT name,id FROM Players WHERE name=%s" % " OR name=".join(["%s" for n in notfound]) | ||||
|             cursor.execute(q2, notfound) # get their new ids | ||||
|             tmp = dict(cursor.fetchall()) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user