tiny thing

This commit is contained in:
lda committed 2025-05-01 22:20:18 +07:00
1 parent 19d28994a2
commit 35fc621883
2 files changed
+14 -16

No files matched your search

+9 -11
View File
@@ -106,7 +106,7 @@ def better_connection_actuallyworking(connectionSettings: dict, conn_name="conn"
# i have to use my own tech # i have to use my own tech
@better_connection_actuallyworking(connectionSettings) @better_connection_actuallyworking(connectionSettings)
def fetchonce_lda( def query_once_fetch_lda(
execute_settings: tuple, execute_settings: tuple,
cursor_settings: dict, cursor_settings: dict,
fetch_many: Literal["one", "many", "all", "warnings"] = "one", fetch_many: Literal["one", "many", "all", "warnings"] = "one",
@@ -114,7 +114,7 @@ def fetchonce_lda(
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:
r.execute(*execute_settings) r.execute(*execute_settings)
match fetch_many: match fetch_many:
@@ -159,7 +159,7 @@ def fulltable(
ifdict = returnType == "dict" ifdict = returnType == "dict"
try: try:
r = fetchonce_lda( r = query_once_fetch_lda(
(f"select * from {tableName}",), (f"select * from {tableName}",),
{"dictionary": ifdict, "prepared": True}, {"dictionary": ifdict, "prepared": True},
fetch_many="all", fetch_many="all",
@@ -186,7 +186,7 @@ def getColumename(
) -> list[str]: ) -> list[str]:
print(tbaleName) print(tbaleName)
try: try:
coln = fetchonce_lda( coln = query_once_fetch_lda(
execute_settings=( execute_settings=(
"select column_name from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = ?", "select column_name from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = ?",
(tbaleName,), (tbaleName,),
@@ -214,7 +214,7 @@ def getTableNmaes(
# ] = None, # ] = None,
) -> list[str]: ) -> list[str]:
try: try:
coln = fetchonce_lda( coln = query_once_fetch_lda(
execute_settings=( execute_settings=(
"select table_name from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = ?", "select table_name from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = ?",
(db_name,), (db_name,),
@@ -257,7 +257,7 @@ def ifTableInDB(
if (vari := ifTableInDB(dbname, tablename)):""" if (vari := ifTableInDB(dbname, tablename)):"""
try: try:
r = fetchonce_lda( r = query_once_fetch_lda(
( (
"select table_name from information_schema.tables where table_schema = ? and table_name = ? Limit 1;", "select table_name from information_schema.tables where table_schema = ? and table_name = ? Limit 1;",
(db_name, tabN), (db_name, tabN),
@@ -467,9 +467,7 @@ def post_endp_lda(self):
updated_Verybreakablequery_insert_into = ( updated_Verybreakablequery_insert_into = (
f"insert into {tabletbale} " f"insert into {tabletbale} "
+ "({0}) values ({0})".format( ## LEARN PYTHON SQL this is nasty f"({','.join(wwwww)}) values ({','.join('?' for _ in wwwww)})"
",".join(("{}",) * len(wwwww)) # incredibly real update
).format(*wwwww, *("?",) * len(wwwww))
) )
print( print(
wwwww, wwwww,
@@ -526,7 +524,7 @@ def openFileManually(
theGuy.header_setup(rescode.NOT_FOUND) theGuy.header_setup(rescode.NOT_FOUND)
theGuy.wfile.write(notfound404) theGuy.wfile.write(notfound404)
return return
elif path.is_dir(): if path.is_dir():
path /= defaultFile path /= defaultFile
if not path.is_file(): if not path.is_file():
theGuy.header_setup(rescode.NOT_FOUND) theGuy.header_setup(rescode.NOT_FOUND)
@@ -609,7 +607,7 @@ def openFileSemiAutomatically(
def get_from_db(self, pathObj): def get_from_db(self, pathObj):
ee = fetchonce_lda( ee = query_once_fetch_lda(
execute_settings=( execute_settings=(
f"select neme, kewod, cod from {tabletbale} where neme = ?;", f"select neme, kewod, cod from {tabletbale} where neme = ?;",
(self.path.lstrip("/"),), (self.path.lstrip("/"),),
+5 -5
View File
@@ -105,7 +105,7 @@ def unpack_with_defaults(t, defaults=(None, (), {})):
# for i in test_subject: # for i in test_subject:
# print( f"{i = },\n{unpack_with_defaults(i) = },\n{maybe_safer_unpack(i) = }\n") # print( f"{i = },\n{unpack_with_defaults(i) = },\n{maybe_safer_unpack(i) = }\n")
# no dont touch this ever
def function_splitter( def function_splitter(
t: tuple[Union[Callable, str], tuple[Any, ...], Dict[str, Any]] = ( t: tuple[Union[Callable, str], tuple[Any, ...], Dict[str, Any]] = (
None, None,
@@ -203,7 +203,7 @@ def funny_trycatch_wrapper(
for oneThing in elses: for oneThing in elses:
res = function_splitter(oneThing) res = function_splitter(oneThing)
superreturn["relses"].append(res) superreturn["relses"].append(res)
finally: # finally:
for oneThing in finallies: for oneThing in finallies:
res = function_splitter(oneThing) res = function_splitter(oneThing)
superreturn["rfinallies"].append(res) superreturn["rfinallies"].append(res)
@@ -239,7 +239,7 @@ def funny_singular_Simple_trycatch(Onetry: tuple):
this = function_splitter(Onetry) this = function_splitter(Onetry)
except BaseException as e: except BaseException as e:
er = e er = e
finally: # finally:
return (this, er) return (this, er)
@@ -312,7 +312,7 @@ def funny_tuples_to_dicts_processor(colname: list[tuple], coldata: list[tuple]):
return new_dicts return new_dicts
getnewdictl = lambda d, l: {k: d[k] for k in d if k in l} # getnewdictl = lambda d, l: {k: d[k] for k in d if k in l}
def getnewdict(d: dict, l: list) -> dict: def getnewdict(d: dict, l: list) -> dict:
@@ -322,7 +322,7 @@ def getnewdict(d: dict, l: list) -> dict:
return {k: d[k] for k in d if k in l} return {k: d[k] for k in d if k in l}
getnewdicttranslatel = lambda d, tltb: {tltb[k]: d[k] for k in d if k in tltb} # getnewdicttranslatel = lambda d, tltb: {tltb[k]: d[k] for k in d if k in tltb}
def getnewdicttranslate(d: dict, tltb: dict) -> dict: def getnewdicttranslate(d: dict, tltb: dict) -> dict: