def write_sources(sources): db_sources = read_sources() for uri in db_sources: if uri not in sources: sql.db_delete(PGA_DB, "sources", 'uri', uri) for uri in sources: if uri not in db_sources: sql.db_insert(PGA_DB, "sources", {'uri': uri})
def add_game(name, runner=None, slug=None, directory=None): """Adds a game to the PGA database.""" if not slug: slug = slugify(name) game_data = {'name': name, 'slug': slug, 'runner': runner} if directory: game_data['directory'] = directory print game_data sql.db_insert(PGA_DB, "games", game_data)
def test_can_create_table(self): fields = [ {'name': 'id', 'type': 'INTEGER', 'indexed': True}, {'name': 'name', 'type': 'TEXT'} ] pga.create_table('testing', fields) sql.db_insert(TEST_PGA_PATH, 'testing', {'name': "testok"}) results = sql.db_select(TEST_PGA_PATH, 'testing', fields=['id', 'name']) self.assertEqual(results[0]['name'], "testok")
def add_game(name, **game_data): """Add a game to the PGA database.""" game_data['name'] = name if 'slug' not in game_data: game_data['slug'] = slugify(name) inserted_id = sql.db_insert(PGA_DB, "games", game_data) return inserted_id
def add_game(name, **game_data): """Add a game to the PGA database.""" game_data["name"] = name game_data["installed_at"] = int(time.time()) if "slug" not in game_data: game_data["slug"] = slugify(name) return sql.db_insert(PGA_DB, "games", game_data)
def add_game(name, **game_data): """Add a game to the PGA database.""" game_data['name'] = name game_data['installed_at'] = int(time.time()) if 'slug' not in game_data: game_data['slug'] = slugify(name) return sql.db_insert(PGA_DB, "games", game_data)
def add_games_bulk(games): """ Add a list of games to the PGA database. The dicts must have an identical set of keys. Args: games (list): list of games in dict format Returns: list: List of inserted game ids """ return [sql.db_insert(PGA_DB, "games", game) for game in games]
def add_games_bulk(games): """Add a list of games to the PGA database. The dicts must have an identical set of keys. :type games: list of dicts """ inserted_ids = [] for game in games: inserted_id = sql.db_insert(PGA_DB, "games", game) inserted_ids.append(inserted_id) return inserted_ids
def add_source(uri): sql.db_insert(PGA_DB, "sources", {"uri": uri})
def add_game(name, **game_data): """Adds a game to the PGA database.""" game_data['name'] = name if not 'slug' in game_data: game_data['slug'] = slugify(name) sql.db_insert(PGA_DB, "games", game_data)
def add_game_to_category(game_id, category_id): """Add a category to a game""" return sql.db_insert(PGA_DB, "games_categories", { "game_id": game_id, "category_id": category_id })
def add_category(category_name): """Add a category to the database""" return sql.db_insert(PGA_DB, "categories", {"name": category_name})