Første commit
This commit is contained in:
commit
c6483fc621
39
NamePropertySearch.py
Normal file
39
NamePropertySearch.py
Normal file
@ -0,0 +1,39 @@
|
||||
import pyodbc
|
||||
from pathlib import Path
|
||||
|
||||
cnxn=pyodbc.connect('driver={sql server};server=bi-dsa-udv\dsa')
|
||||
p=Path('F:/Users/admindenker/TFS Workspace/Datavarehus')
|
||||
|
||||
def traverseDirectory(x):
|
||||
if (x.name=='obj' or x.name.strip()=='DataPresentationArea' or x.name=='FastTrack' or x.name=='Undervisning' or x.name=='Udvikling'):
|
||||
# print(x.name)
|
||||
return
|
||||
[checkFile(z) for z in x.iterdir() if z.is_file and z.name.endswith('.dtsx')]
|
||||
[traverseDirectory(y) for y in x.iterdir() if y.is_dir()]
|
||||
def checkFile(file):
|
||||
f=open(file,"r", encoding='utf-8')
|
||||
for x in f:
|
||||
if(x.find("DTS:ObjectName")>-1):
|
||||
propertyNameTokens=x.split('=')
|
||||
count=0
|
||||
while count < len(propertyNameTokens):
|
||||
if(propertyNameTokens[count].find("DTS:ObjectName")>-1):
|
||||
propertyNameToken=propertyNameTokens[count+1].split('"')[1]
|
||||
break
|
||||
count+=2
|
||||
if(file.stem!=propertyNameToken):
|
||||
ssisproject=[a for a in file.parts if a.find("SSIS_")>-1]
|
||||
if(len(ssisproject)>0):
|
||||
insertIntoTable(ssisproject[0],str(file.parent),str(file.stem),propertyNameToken)
|
||||
print(ssisproject[0] + ' ' + str(file.parent) + ' ' + file.stem + ' ' + propertyNameToken)
|
||||
print(x)
|
||||
break
|
||||
else:
|
||||
continue
|
||||
f.close()
|
||||
def insertIntoTable(ssisproject,tfspath,packagename,packagenameproperty):
|
||||
curser.execute("insert into [UDV_denker].[dbo].[ssispackages](SSISProject,tfspath,PackageName,PackageNameProperty,ITPUpdate,ITUUpdate) values (?,?,?,?,?,?)",(ssisproject,tfspath,packagename,packagenameproperty,0,0))
|
||||
|
||||
curser=cnxn.cursor()
|
||||
[traverseDirectory(x) for x in p.iterdir() if x.is_dir()]
|
||||
cnxn.commit()
|
||||
Loading…
x
Reference in New Issue
Block a user