@@ -141,10 +141,9 @@ def __init__(self, category, url: str = "https://bpsapi.rajtech.me/v1/", cache_m
141141 self ._con = sqlite3 .connect (self .db_path + f"/{ self .db_name } .db" )
142142 self ._cur = self ._con .cursor ()
143143
144- self ._cur .execute ("CREATE TABLE IF NOT EXISTS ? (title TEXT, category TEXT, data BLOB)" ,
145- (self .db_table ,))
146- self ._cur .execute ("INSERT INTO ? VALUES (?, ?, ?)" ,
147- (self .db_table , "circular_list" , self .category , pickle .dumps ([])))
144+ self ._cur .execute (f"CREATE TABLE IF NOT EXISTS { self .db_table } (title TEXT, category TEXT, data BLOB)" )
145+ self ._cur .execute (f"INSERT INTO { self .db_table } VALUES (?, ?, ?)" ,
146+ ("circular_list" , self .category , pickle .dumps ([])))
148147 self ._con .commit ()
149148
150149 elif cache_method == "pickle" :
@@ -180,7 +179,7 @@ def refresh_db_con(self):
180179 def get_cache (self ) -> list [list ]:
181180 if self .cache_method == "database" :
182181 self .refresh_db_con ()
183- self ._cur .execute ("SELECT * FROM ? WHERE category = ?" , (self .db_table , self . category ))
182+ self ._cur .execute (f "SELECT * FROM { self . db_table } WHERE category = ?" , (self .category , ))
184183 res = self ._cur .fetchone ()
185184 if res is None :
186185 return []
@@ -198,9 +197,9 @@ def get_cache(self) -> list[list]:
198197 def _set_cache (self , data , title : str = "circular_list" ):
199198 if self .cache_method == "database" :
200199 self .refresh_db_con ()
201- self ._cur .execute ("DELETE FROM ? WHERE category = ?" , (self . db_table , self .category ,))
202- self ._cur .execute ("INSERT INTO ? VALUES (?, ?, ?)" ,
203- (self . db_table , title , self .category , pickle .dumps (data )))
200+ self ._cur .execute (f "DELETE FROM { self . db_table } WHERE category = ?" , (self .category ,))
201+ self ._cur .execute (f "INSERT INTO { self . db_table } VALUES (?, ?, ?)" ,
202+ (title , self .category , pickle .dumps (data )))
204203 self ._con .commit ()
205204
206205 elif self .cache_method == "pickle" :
0 commit comments