我确实对我前面写的我的手稿感到麻烦,试图用我的手法阅读,也执行。 在这里,我简单的我的手稿被删除。
DROP FUNCTION IF EXISTS `employee_db`.`func_create_token`;
CREATE FUNCTION `employee_db`.`func_create_token`() RETURNS VARCHAR(100) DETERMINISTIC
BEGIN
DECLARE `chars` VARCHAR(26);
DECLARE `charLen` INT;
DECLARE `randomPassword` VARCHAR(100);
SET `chars` = ABCDEFGHIJKLMNOPQRSTUVWXYZ ;
SET `charLen` = LENGTH(`chars`);
SET `randomPassword` = ;
WHILE LENGTH(`randomPassword`) < 12 DO
SET `randomPassword` = CONCAT(`randomPassword`, SUBSTRING(`chars`, CEILING(RAND() * `charLen`), 1));
END WHILE;
RETURN `randomPassword`;
END;
我能够直接执行这一职能。 迄今没有任何问题。 但是,试图读一下金字的q子,然后加以执行,总是会导致错误,我有些how可以解决。 下面请看一看 p的功能:
# Function to execute sql file
def execute_sql_script(path_to_sql: os.PathLike[str], title: str) -> None:
# Read sql file from folder `sql`
try:
with open(path_to_sql, r ) as f:
queries : list = f.read().split( ; )
queries : list = [q.strip() for q in queries if q.strip()]
f.close()
except FileNotFoundError as f:
print(color.BOLD + color.RED + f File couldn t be read. Please check error: {e} + color.END)
# Execute sql script with progress bar
try:
with alive_bar(len(queries), dual_line = True, title = title, force_tty = True) as bar:
for _, query in enumerate(queries):
sleep(.05)
cursor.execute(query)
bar()
cursor.commit()
except Error as e:
print(color.BOLD + color.RED + f Error in executing sql script. Check error: {e} + color.END)
错误信息非常有用:
Create Function - Employee |███▋⚠︎ | (!) 1/11 [
[1m[91mError in executing sql script. Check error: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near at line 3[0m
奇怪的是,每处表格的所有其他文字的执行,都是热情的,没有任何例外。
Create Function - Employee |████████████████████████████████████████| 27/27 [100