@@ -82,8 +82,7 @@ def generate_name(name: str):
8282
8383 self .cursor .execute (
8484 f"INSERT INTO { self .name } ({ names [:- 1 ]} ) VALUES ({ values [:- 1 ]} )"
85- )
86- self .cursor .commit ()
85+ ).commit ()
8786
8887 return self
8988
@@ -146,14 +145,47 @@ def __init__(
146145 """
147146 self .null = NULL
148147 self .NULL = self .null
149- self ._query = None
150- self ._execution = None
148+ # setting null constant so user will be able to easily access it
149+
150+ self ._empty_query () # set query to None
151151
152152 super ().__init__ (__cursor )
153+
153154 self ._logger = logging .getLogger (
154155 "fyCursor"
155156 ) if logger is None else logger
156157
158+ def set_logger (self , logger : Any ) -> Self :
159+ """
160+ Sets a custom logger. Logger class should have following methods: \
161+ info, warning, exception
162+
163+ :param logger: - logger
164+ :returns: - self
165+ """
166+ self ._logger = logger
167+
168+ return self
169+
170+ def _empty_query (self ) -> None :
171+ self ._execution = self ._query = None
172+
173+ def check_method (self , * methods : str ) -> bool :
174+ """
175+ Checks if provided methods are qurrently in query
176+
177+ :*methods: - str name of methods
178+ :returns: - bool
179+ """
180+ if len (methods ) > 1 :
181+ return False not in [self .check_method (method )
182+ for method in methods ]
183+ elif not methods :
184+ return True
185+ elif self ._query is None :
186+ return False
187+ return methods [1 ] in self ._query
188+
157189 def update (self , table : str ) -> Self :
158190 """
159191 Use this as SQL `UPDATE {table}` method
@@ -162,6 +194,7 @@ def update(self, table: str) -> Self:
162194 :returns: - self
163195 """
164196 self ._query = f"UPDATE { table } "
197+
165198 return self
166199
167200 def add (self , ** kwargs : Any ) -> Self :
@@ -237,16 +270,24 @@ def where(self, **kwargs: Any) -> Self:
237270 )
238271 return self
239272
240- def execute ( # type: ignore
273+ def execute (
241274 self ,
242275 __sql : str ,
243276 * __parameters : Any
244277 ) -> Self :
245278 if __parameters :
246- for param in __parameters : # type: ignore
247- __sql = __sql .replace ("?" , str (param ), 1 ) # type: ignore
279+ for param in __parameters :
280+ __sql = __sql .replace ("?" , str (param ), 1 )
248281 self ._execution = __sql
249- return super ().execute (__sql ) # type: ignore
282+ return self
283+
284+ def exec (self , __sql : Any , __parameters : Any = ()):
285+ """
286+ Execute using super().execute
287+
288+ Use if bugs appered in fyCursor.execute
289+ """
290+ return super ().execute (__sql , __parameters )
250291
251292 def fetch (
252293 self ,
@@ -260,10 +301,12 @@ def fetch(
260301 """
261302 if not self ._query and not self ._execution :
262303 raise ProgrammingError ("Nothing to fetch" )
263- print ( self . _query , self . _execution )
304+
264305 super ().execute (self ._query or self ._execution ) # type: ignore
265306 super ().connection .commit ()
266- self ._execution = self ._query = None
307+
308+ self ._empty_query ()
309+
267310 return super ().fetchone () if one else super ().fetchall ()
268311
269312 def one (self ) -> Any :
@@ -280,12 +323,14 @@ def one(self) -> Any:
280323
281324 def commit (self ) -> Self :
282325 if self ._execution :
326+ print (self ._execution )
283327 super ().execute (self ._execution )
284328 elif self ._query :
285329 super ().execute (self ._query )
286- self ._execution = self ._query = None
287-
288330 super ().connection .commit ()
331+
332+ self ._empty_query ()
333+
289334 return self
290335
291336 def create_table (
0 commit comments