mercredi 24 février 2016

Execute select on sqlite db using pythonic data

I have sqlite select query and can't see what is going wrong.

team_id, season_type, season, game_date = 'some_id', '2014-15', 'Some Season', '2015-00-00T00:00:00'

cur.execute('SELECT teams_stats_in_game.rebounds FROM teams_stats_in_game '
                        'INNER JOIN games'
                            'ON games.id = teams_stats_in_game.game_id '
                                'AND games.home_team_id = teams_stats_in_game.team_id '
                        'WHERE games.home_team_id = %s '
                            'AND games.season_type = %s '
                            'AND games.season = %s '
                            'AND games.date_est < %s '
                        'ORDER BY games.date_est DESC' % (team_id, season_type, season, game_date))

Trace:

Traceback (most recent call last):
'ORDER BY games.date_est DESC' % (team_id, season_type, season, game_date))
OperationalError: near "Season": syntax error

Aucun commentaire:

Enregistrer un commentaire