| 17 |
|
|
| 18 |
|
class Eclipse_Connection(object): |
| 19 |
|
"""An Advanced Eclipse Connection Library and Toolkit""" |
| 20 |
< |
version = '0.6.0' |
| 20 |
> |
version = '0.7.0' |
| 21 |
> |
sqlUserName = "eborges" |
| 22 |
> |
|
| 23 |
> |
## Only add when compiling!!! |
| 24 |
> |
sqlPassword = '' |
| 25 |
> |
|
| 26 |
> |
|
| 27 |
|
|
| 28 |
|
def __init__(self): |
| 29 |
|
self.caseMatrix = None |
| 37 |
|
self.tagGroupToTagNameMatrix = None |
| 38 |
|
self._UpdateCaseMatrix() |
| 39 |
|
print "\nEclipse SQL Library Initialized.\n\nCreated by Emanuel Borges\nVersion %s\n\n"% self.version |
| 40 |
+ |
|
| 41 |
+ |
def _GetNewCnxn(self, internalCaseName): |
| 42 |
+ |
"""A simple funtion, not method and does not update any instance vars, to grab a new cnxn connection. Just to have one place to keep this line updated""" |
| 43 |
+ |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;Trusted_Connection=yes;"%internalCaseName) |
| 44 |
+ |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;UID=%s;PWD=%s;Trusted_Connection=NO;"%(internalCaseName,self.sqlUserName, self.sqlPassword)) |
| 45 |
+ |
return cnxn |
| 46 |
|
|
| 47 |
|
def _UpdateCaseMatrix(self): |
| 48 |
|
"""Will normally run only once when initiated, which populates the case Matrix and the sorted case list.""" |
| 49 |
|
matrix = {} |
| 50 |
|
|
| 51 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=AddConfig;""Trusted_Connection=yes;") |
| 51 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=AddConfig;""Trusted_Connection=yes;") |
| 52 |
> |
cnxn = self._GetNewCnxn('AddConfig') |
| 53 |
|
cursor = cnxn.cursor() |
| 54 |
|
|
| 55 |
|
cursor.execute('select name,databasename from Enterprise.CaseProductEnvironment where ProductId=3') |
| 68 |
|
batchSetList = [] |
| 69 |
|
internalCaseName = self.caseMatrix[self.currentDatabaseName] |
| 70 |
|
|
| 71 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 71 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 72 |
> |
cnxn = self._GetNewCnxn(internalCaseName) |
| 73 |
|
cursor = cnxn.cursor() |
| 74 |
|
|
| 75 |
|
cursor.execute('SELECT ReviewPassName FROM Review.ReviewPass ORDER BY ReviewPassName') |
| 95 |
|
|
| 96 |
|
internalCaseName = self.caseMatrix[self.currentDatabaseName] |
| 97 |
|
|
| 98 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 98 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 99 |
> |
cnxn = self._GetNewCnxn(internalCaseName) |
| 100 |
|
cursor = cnxn.cursor() |
| 101 |
|
|
| 102 |
|
cursor.execute("SELECT TagGroups.TagGroupName, Tags.TagName, TagGroupsDetail.TagGroupId, TagGroupsDetail.TagId FROM TagGroups INNER JOIN TagGroupsDetail ON TagGroups.TagGroupId = TagGroupsDetail.TagGroupId INNER JOIN Tags ON TagGroupsDetail.TagId = Tags.TagId") |
| 121 |
|
|
| 122 |
|
internalCaseName = self.caseMatrix[self.currentDatabaseName] |
| 123 |
|
|
| 124 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 124 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 125 |
> |
cnxn = self._GetNewCnxn(internalCaseName) |
| 126 |
|
cursor = cnxn.cursor() |
| 127 |
|
|
| 128 |
|
cursor.execute("SELECT Tags.TagName, Documents.DocumentKey FROM TagGroupsDetail INNER JOIN TagGroups ON TagGroupsDetail.TagGroupId = TagGroups.TagGroupId INNER JOIN Tags ON TagGroupsDetail.TagId = Tags.TagId INNER JOIN DocumentTags ON Tags.TagId = DocumentTags.TagId INNER JOIN Documents ON DocumentTags.DocId = Documents.DocId WHERE (Tags.TagName = '%s') ORDER BY DocumentKey"% tagName) |
| 154 |
|
|
| 155 |
|
internalCaseName = self.caseMatrix[caseName] |
| 156 |
|
|
| 157 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 157 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 158 |
> |
cnxn = self._GetNewCnxn(internalCaseName) |
| 159 |
|
cursor = cnxn.cursor() |
| 160 |
|
|
| 161 |
|
cursor.execute('SELECT TableName, ColumnName, FieldName FROM vFieldDefinition') |
| 178 |
|
|
| 179 |
|
internalCaseName = self.caseMatrix[self.currentDatabaseName] |
| 180 |
|
|
| 181 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 181 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 182 |
> |
cnxn = self._GetNewCnxn(internalCaseName) |
| 183 |
|
cursor = cnxn.cursor() |
| 184 |
|
|
| 185 |
|
internalTableName, internalFieldName = self.fieldMatrix[fieldName] |
| 201 |
|
|
| 202 |
|
internalCaseName = self.caseMatrix[self.currentDatabaseName] |
| 203 |
|
|
| 204 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 204 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 205 |
> |
cnxn = self._GetNewCnxn(internalCaseName) |
| 206 |
|
cursor = cnxn.cursor() |
| 207 |
|
|
| 208 |
|
cursor.execute('Select top 10000 b.CategoryName, c.DocumentKey, a.IsEntireDocument, a.DocumentText FROM Analytics.CategoryExemplarDocument a left join [Analytics].[Category] b on b.CategoryId=a.CategoryId left join dbo.documents c on c.docid=a.docid order by 2 asc') |
| 231 |
|
"""Returns the total production size, in GB, for a production with the volume of the voumeValue you give it. It rounds the number and, if you are under .01 it will just make it .01. Finally also returns 0.0 if the value was empty.""" |
| 232 |
|
internalCaseName = self.caseMatrix[self.currentDatabaseName] |
| 233 |
|
|
| 234 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 234 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 235 |
> |
cnxn = self._GetNewCnxn(internalCaseName) |
| 236 |
|
cursor = cnxn.cursor() |
| 237 |
|
|
| 238 |
|
internalProdVolTableName, internalProdVolFieldName = self.fieldMatrix[prodVolFieldName] |
| 267 |
|
"""Updates the endDocField, filtering by a tag, but only the null value ones, by copying from the evidoxID field""" |
| 268 |
|
internalCaseName = self.caseMatrix[self.currentDatabaseName] |
| 269 |
|
|
| 270 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 270 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 271 |
> |
cnxn = self._GetNewCnxn(internalCaseName) |
| 272 |
|
cursor = cnxn.cursor() |
| 273 |
|
|
| 274 |
|
cursor.execute("SELECT Tags.TagName, Documents.DocumentKey FROM TagGroupsDetail INNER JOIN TagGroups ON TagGroupsDetail.TagGroupId = TagGroups.TagGroupId INNER JOIN Tags ON TagGroupsDetail.TagId = Tags.TagId INNER JOIN DocumentTags ON Tags.TagId = DocumentTags.TagId INNER JOIN Documents ON DocumentTags.DocId = Documents.DocId WHERE (Tags.TagName = '%s') ORDER BY DocumentKey"% tagName) |
| 279 |
|
"""Updates the batch reviewed status flag for a particular batch set by name. default is to query only, which wont actually do any updates and only return the count""" |
| 280 |
|
internalCaseName = self.caseMatrix[self.currentDatabaseName] |
| 281 |
|
|
| 282 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 282 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 283 |
> |
cnxn = self._GetNewCnxn(internalCaseName) |
| 284 |
|
cursor = cnxn.cursor() |
| 285 |
|
|
| 286 |
|
|
| 302 |
|
"""Generates a pipe delimited report from the saved searches""" |
| 303 |
|
internalCaseName = self.caseMatrix[self.currentDatabaseName] |
| 304 |
|
|
| 305 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 305 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 306 |
> |
cnxn = self._GetNewCnxn(internalCaseName) |
| 307 |
|
cursor = cnxn.cursor() |
| 308 |
|
|
| 309 |
|
## First grab the parent folder matrix and prepopulate the -1 and 0 folders |
| 338 |
|
"""Runs a database defrag on the current database. default is viewonly, which wont actually run it. overide by setting to false to run""" |
| 339 |
|
internalCaseName = self.caseMatrix[self.currentDatabaseName] |
| 340 |
|
|
| 341 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 341 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 342 |
> |
cnxn = self._GetNewCnxn(internalCaseName) |
| 343 |
|
cursor = cnxn.cursor() |
| 344 |
|
|
| 345 |
|
## with the db selected, now execute the sp_updatestats part |
| 348 |
|
cnxn.close() |
| 349 |
|
print "SP_UpdateStats finished." |
| 350 |
|
|
| 351 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=evdxAdmin;""Trusted_Connection=yes;") |
| 351 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=evdxAdmin;""Trusted_Connection=yes;") |
| 352 |
> |
cnxn = self._GetNewCnxn('evdxAdmin') |
| 353 |
|
cursor = cnxn.cursor() |
| 354 |
|
|
| 355 |
|
|
| 358 |
|
cursor.execute("exec ap_rebuildindexes @databasename = '%s'"%internalCaseName) |
| 359 |
|
print "rebuildIndexes finished" |
| 360 |
|
|
| 361 |
< |
cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 361 |
> |
#cnxn = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};""Server=XIPRORVW01\XIPRORVW01;""Database=%s;""Trusted_Connection=yes;"%internalCaseName) |
| 362 |
> |
cnxn = self._GetNewCnxn(internalCaseName) |
| 363 |
|
cursor = cnxn.cursor() |
| 364 |
|
|
| 365 |
|
## Now read and run the rest by way of a blob. |