make_sql.py
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/evn python
# coding=utf-8
import json,os
rootdir='C:\Users\Administrator\Desktop\\faces'
#list = os.listdir(rootdir)
#for i in range(0,len(list)):
# path = os.path.join(rootdir,list[i])
# print path
# if os.path.isfile(path):
# print path
def gci (path):
"""this is a statement"""
parents = os.listdir(path)
for parent in parents:
child = os.path.join(path,parent)
if os.path.isdir(child):
#for root, dirs, files in os.walk ( child ):
#print(root) # 当前目录路径
#print(dirs) # 当前路径下所有子目录
# print(files) # 当前路径下所有非目录子文件
gci(child)
else:
strs = child[child.index('faces\\'):]
strs = strs.replace('\\','/')
format = strs[strs.index('.')+1:]
filename = strs[strs.rfind('/')+1:]
filename = filename[0:filename.index('.')]
#print filename
#print format
#print strs
#print(os.path.splitext(child)[0])
print ('INSERT INTO tb_pic_metadata (pic_unid, md5, size, pic_refid, pic_url, format, ofilename, create_td, upload_td, modify_td, grid_id, sha1) '
' VALUES (\'%s\', NULL, \'321577\', \'%s\', \'%s\', \'%s\', \'undefined\', \'2019-05-13 01:23:59.252\', NULL, NULL, NULL, NULL);' % (filename,filename,strs,format)
)
#print('child=%s' % child)
gci(rootdir)