在指定的路径下,递归获取所有sql文件
# -*- coding: utf-8 -*-
"""
@Author : Diao
@Time : 2021/5/8
@Comment : Get the SQL file recursively under the specified path
"""
from glob import glob
import os
def glob_files(dir_path):
file_list = glob(os.path.join(dir_path, '*.sql'))
sub_dir = os.listdir(dir_path)
for sub_dir_name in sub_dir:
if os.path.isdir(os.path.join(dir_path, sub_dir_name)):
file_list.extend(glob_files(os.path.join(dir_path, sub_dir_name)))
return file_list
if __name__ == '__main__':
print(glob_files('d:\\temp'))