logic change
This commit is contained in:
1 parent
20412d225e
commit
22647dce11
1 file changed
+12
-6
+12
-6
@@ -105,7 +105,7 @@ def better_connection_actuallyworking(connectionSettings: dict, conn_name="conn"
|
|||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
fn: TypeAlias = Literal["one", "many", "all", "warnings"]
|
fetch_many_t: TypeAlias = Literal["one", "many", "all", "warnings"]
|
||||||
|
|
||||||
|
|
||||||
# i have to use my own tech
|
# i have to use my own tech
|
||||||
@@ -113,14 +113,14 @@ fn: TypeAlias = Literal["one", "many", "all", "warnings"]
|
|||||||
def query_once_fetch_lda(
|
def query_once_fetch_lda(
|
||||||
execute_settings: tuple,
|
execute_settings: tuple,
|
||||||
cursor_settings: dict,
|
cursor_settings: dict,
|
||||||
fetch_many: fn | Collection[fn] = "one",
|
fetch_many: fetch_many_t | Collection[fetch_many_t] = "one",
|
||||||
*,
|
*,
|
||||||
conn=None,
|
conn=None,
|
||||||
):
|
):
|
||||||
"every thing passes to execute, return fetchone. lda test"
|
"every thing passes to execute, return fetchone. lda test"
|
||||||
# print("i seqeralr", conn)
|
# print("i seqeralr", conn)
|
||||||
with conn.cursor(**cursor_settings) as r:
|
with conn.cursor(**cursor_settings) as r:
|
||||||
rf: dict[fn, Callable] = {
|
rf: dict[fetch_many_t, Callable] = {
|
||||||
"one": r.fetchone,
|
"one": r.fetchone,
|
||||||
"all": r.fetchall,
|
"all": r.fetchall,
|
||||||
"many": r.fetchmany,
|
"many": r.fetchmany,
|
||||||
@@ -128,15 +128,21 @@ def query_once_fetch_lda(
|
|||||||
}
|
}
|
||||||
r.execute(*execute_settings)
|
r.execute(*execute_settings)
|
||||||
|
|
||||||
|
try:
|
||||||
if isinstance(fetch_many, str):
|
if isinstance(fetch_many, str):
|
||||||
return rf[fetch_many]()
|
ef = rf[fetch_many]()
|
||||||
if isinstance(fetch_many, Collection):
|
elif isinstance(fetch_many, Collection): # not a string hahahahah
|
||||||
return tuple(rf[i]() for i in fetch_many)
|
ef = tuple(rf[i]() for i in fetch_many)
|
||||||
|
else:
|
||||||
raise AttributeError(
|
raise AttributeError(
|
||||||
f"please put one of the one, many, all, warnings in ty (you put {fetch_many})",
|
f"please put one of the one, many, all, warnings in ty (you put {fetch_many})",
|
||||||
name=fetch_many,
|
name=fetch_many,
|
||||||
obj=r,
|
obj=r,
|
||||||
)
|
)
|
||||||
|
except (TypeError, KeyError): # calling None exception
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ef
|
||||||
|
|
||||||
|
|
||||||
@better_connection_actuallyworking(connectionSettings)
|
@better_connection_actuallyworking(connectionSettings)
|
||||||
|
|||||||
Reference in new issue
Block a user