diff --git a/conan/internal/cache/db/packages_table.py b/conan/internal/cache/db/packages_table.py index 7d093197b39..a5ec13b7a51 100644 --- a/conan/internal/cache/db/packages_table.py +++ b/conan/internal/cache/db/packages_table.py @@ -39,7 +39,7 @@ def _where_clause(self, pref: PkgReference): self.columns.prev: pref.revision, } where_expr = ' AND '.join( - [f'{k}="{v}" ' if v is not None else f'{k} IS NULL' for k, v in where_dict.items()]) + [f"{k}='{v}' " if v is not None else f'{k} IS NULL' for k, v in where_dict.items()]) return where_expr def _set_clause(self, pref: PkgReference, path=None, build_id=None): @@ -52,7 +52,7 @@ def _set_clause(self, pref: PkgReference, path=None, build_id=None): self.columns.timestamp: pref.timestamp, self.columns.build_id: build_id, } - set_expr = ', '.join([f'{k} = "{v}"' for k, v in set_dict.items() if v is not None]) + set_expr = ', '.join([f"{k} = '{v}'" for k, v in set_dict.items() if v is not None]) return set_expr def get(self, pref: PkgReference): @@ -107,7 +107,7 @@ def update_lru(self, pref): where_clause = self._where_clause(pref) lru = timestamp_now() query = f"UPDATE {self.table_name} " \ - f'SET {self.columns.lru} = "{lru}" ' \ + f"SET {self.columns.lru} = '{lru}' " \ f"WHERE {where_clause};" with self.db_connection() as conn: conn.execute(query) @@ -115,7 +115,7 @@ def update_lru(self, pref): def remove_build_id(self, pref): where_clause = self._where_clause(pref) query = f"UPDATE {self.table_name} " \ - f'SET {self.columns.build_id} = "null" ' \ + f"SET {self.columns.build_id} = 'null' " \ f"WHERE {where_clause};" with self.db_connection() as conn: try: @@ -126,8 +126,8 @@ def remove_build_id(self, pref): def remove_recipe(self, ref: RecipeReference): # can't use the _where_clause, because that is an exact match on the package_id, etc query = f"DELETE FROM {self.table_name} " \ - f'WHERE {self.columns.reference} = "{str(ref)}" ' \ - f'AND {self.columns.rrev} = "{ref.revision}" ' + f"WHERE {self.columns.reference} = '{str(ref)}' " \ + f"AND {self.columns.rrev} = '{ref.revision}' " with self.db_connection() as conn: conn.execute(query) @@ -141,7 +141,7 @@ def remove(self, pref: PkgReference): def get_package_revisions_references(self, pref: PkgReference, only_latest_prev=False): assert pref.ref.revision, "To search package revisions you must provide a recipe revision." assert pref.package_id, "To search package revisions you must provide a package id." - check_prev = f'AND {self.columns.prev} = "{pref.revision}" ' if pref.revision else '' + check_prev = f"AND {self.columns.prev} = '{pref.revision}' " if pref.revision else "" if only_latest_prev: query = f'SELECT {self.columns.reference}, ' \ f'{self.columns.rrev}, ' \ @@ -152,17 +152,17 @@ def get_package_revisions_references(self, pref: PkgReference, only_latest_prev= f'{self.columns.build_id}, ' \ f'{self.columns.lru} ' \ f'FROM {self.table_name} ' \ - f'WHERE {self.columns.rrev} = "{pref.ref.revision}" ' \ - f'AND {self.columns.reference} = "{str(pref.ref)}" ' \ - f'AND {self.columns.pkgid} = "{pref.package_id}" ' \ + f"WHERE {self.columns.rrev} = '{pref.ref.revision}' " \ + f"AND {self.columns.reference} = '{str(pref.ref)}' " \ + f"AND {self.columns.pkgid} = '{pref.package_id}' " \ f'{check_prev} ' \ f'AND {self.columns.prev} IS NOT NULL ' \ f'GROUP BY {self.columns.pkgid} ' else: query = f'SELECT * FROM {self.table_name} ' \ - f'WHERE {self.columns.rrev} = "{pref.ref.revision}" ' \ - f'AND {self.columns.reference} = "{str(pref.ref)}" ' \ - f'AND {self.columns.pkgid} = "{pref.package_id}" ' \ + f"WHERE {self.columns.rrev} = '{pref.ref.revision}' " \ + f"AND {self.columns.reference} = '{str(pref.ref)}' " \ + f"AND {self.columns.pkgid} = '{pref.package_id}' " \ f'{check_prev} ' \ f'AND {self.columns.prev} IS NOT NULL ' \ f'ORDER BY {self.columns.timestamp} DESC' @@ -185,13 +185,13 @@ def get_package_references(self, ref: RecipeReference, only_latest_prev=True): f'{self.columns.build_id}, ' \ f'{self.columns.lru} ' \ f'FROM {self.table_name} ' \ - f'WHERE {self.columns.rrev} = "{ref.revision}" ' \ - f'AND {self.columns.reference} = "{str(ref)}" ' \ + f"WHERE {self.columns.rrev} = '{ref.revision}' " \ + f"AND {self.columns.reference} = '{str(ref)}' " \ f'GROUP BY {self.columns.pkgid} ' else: query = f'SELECT * FROM {self.table_name} ' \ - f'WHERE {self.columns.rrev} = "{ref.revision}" ' \ - f'AND {self.columns.reference} = "{str(ref)}" ' \ + f"WHERE {self.columns.rrev} = '{ref.revision}' " \ + f"AND {self.columns.reference} = '{str(ref)}' " \ f'AND {self.columns.prev} IS NOT NULL ' \ f'ORDER BY {self.columns.timestamp} DESC' with self.db_connection() as conn: diff --git a/conan/internal/cache/db/recipes_table.py b/conan/internal/cache/db/recipes_table.py index 38bbb3d2da2..fe40ab56782 100644 --- a/conan/internal/cache/db/recipes_table.py +++ b/conan/internal/cache/db/recipes_table.py @@ -33,7 +33,7 @@ def _where_clause(self, ref): self.columns.rrev: ref.revision, } where_expr = ' AND '.join( - [f'{k}="{v}" ' if v is not None else f'{k} IS NULL' for k, v in where_dict.items()]) + [f"{k}='{v}' " if v is not None else f'{k} IS NULL' for k, v in where_dict.items()]) return where_expr def create(self, path, ref: RecipeReference): @@ -54,9 +54,9 @@ def update_timestamp(self, ref: RecipeReference): assert ref.revision is not None assert ref.timestamp is not None query = f"UPDATE {self.table_name} " \ - f'SET {self.columns.timestamp} = "{ref.timestamp}" ' \ - f'WHERE {self.columns.reference}="{str(ref)}" ' \ - f'AND {self.columns.rrev} = "{ref.revision}" ' + f"SET {self.columns.timestamp} = '{ref.timestamp}' " \ + f"WHERE {self.columns.reference}='{str(ref)}' " \ + f"AND {self.columns.rrev} = '{ref.revision}' " with self.db_connection() as conn: conn.execute(query) @@ -66,7 +66,7 @@ def update_lru(self, ref): where_clause = self._where_clause(ref) lru = timestamp_now() query = f"UPDATE {self.table_name} " \ - f'SET {self.columns.lru} = "{lru}" ' \ + f"SET {self.columns.lru} = '{lru}' " \ f"WHERE {where_clause};" with self.db_connection() as conn: conn.execute(query) @@ -95,8 +95,8 @@ def all_references(self): def get_recipe(self, ref: RecipeReference): query = f'SELECT * FROM {self.table_name} ' \ - f'WHERE {self.columns.reference}="{str(ref)}" ' \ - f'AND {self.columns.rrev} = "{ref.revision}" ' + f"WHERE {self.columns.reference}='{str(ref)}' " \ + f"AND {self.columns.rrev} = '{ref.revision}' " with self.db_connection() as conn: r = conn.execute(query) row = r.fetchone() @@ -112,7 +112,7 @@ def get_latest_recipe(self, ref: RecipeReference): f'MAX({self.columns.timestamp}), ' \ f'{self.columns.lru} ' \ f'FROM {self.table_name} ' \ - f'WHERE {self.columns.reference} = "{str(ref)}" ' \ + f"WHERE {self.columns.reference} = '{str(ref)}' " \ f'GROUP BY {self.columns.reference} ' # OTHERWISE IT FAILS THE MAX() with self.db_connection() as conn: @@ -126,7 +126,7 @@ def get_latest_recipe(self, ref: RecipeReference): def get_recipe_revisions_references(self, ref: RecipeReference): assert ref.revision is None query = f'SELECT * FROM {self.table_name} ' \ - f'WHERE {self.columns.reference} = "{str(ref)}" ' \ + f"WHERE {self.columns.reference} = '{str(ref)}' " \ f'ORDER BY {self.columns.timestamp} DESC' with self.db_connection() as conn: diff --git a/conans/client/store/localdb.py b/conans/client/store/localdb.py index 9ae82f9ebf1..8525256b60e 100644 --- a/conans/client/store/localdb.py +++ b/conans/client/store/localdb.py @@ -49,7 +49,7 @@ def clean(self, remote_url=None): cursor = connection.cursor() query = "DELETE FROM %s" % REMOTES_USER_TABLE if remote_url: - query += ' WHERE remote_url="{}"'.format(remote_url) + query += " WHERE remote_url='{}'".format(remote_url) cursor.execute(query) try: # https://github.com/ghaering/pysqlite/issues/109 @@ -74,7 +74,7 @@ def get_login(self, remote_url): with self._connect() as connection: try: statement = connection.cursor() - statement.execute('select user, token, refresh_token from %s where remote_url="%s"' + statement.execute("select user, token, refresh_token from %s where remote_url='%s'" % (REMOTES_USER_TABLE, remote_url)) rs = statement.fetchone() if not rs: