Initial commit
This commit is contained in:
37
GetFunctions.py
Normal file
37
GetFunctions.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import hashlib
|
||||
|
||||
|
||||
def create_entry_hash(cfilename, isize, ctime, mtime):
|
||||
entryhash = ""
|
||||
entryhash = hashlib.md5(
|
||||
cfilename.upper().encode() + str(isize).encode() + str(ctime).encode() + str(mtime).encode()).hexdigest()
|
||||
return (entryhash)
|
||||
|
||||
|
||||
def create_filename_hash(cfilename):
|
||||
filenamehash = ""
|
||||
filenamehash = hashlib.md5(cfilename.upper().encode()).hexdigest()
|
||||
return (filenamehash)
|
||||
|
||||
|
||||
def delete_all_from_tfolders(cursor, connection):
|
||||
cursor.execute("delete from tFolders")
|
||||
connection.commit()
|
||||
|
||||
|
||||
def check_folder_exists(folder, connection):
|
||||
curtmp = connection.cursor()
|
||||
escfolder = connection.escape_string(folder)
|
||||
print(escfolder)
|
||||
pocettmp = curtmp.execute("select id from tFolders where cfoldername=%s", escfolder)
|
||||
if pocettmp == 0:
|
||||
return [0, 0]
|
||||
else:
|
||||
return [pocettmp, curtmp.fetchone()[0]]
|
||||
|
||||
|
||||
def set_sql_mode_no_escape(cursor):
|
||||
cursor.execute("SELECT @@sql_mode")
|
||||
newmode = cursor.fetchone()[0]
|
||||
newmode = newmode + ",NO_BACKSLASH_ESCAPES"
|
||||
cursor.execute("set @@sql_mode=%s", newmode)
|
||||
Reference in New Issue
Block a user