-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_dataSet.py
More file actions
27 lines (24 loc) · 779 Bytes
/
_dataSet.py
File metadata and controls
27 lines (24 loc) · 779 Bytes
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
import pyodbc
import json
import collections
cnxn = pyodbc.connect('DRIVER={SQL Server Native Client 11.0};SERVER=WIN8\MSSQL2K12;DATABASE=LogMe;UID=LogMe;PWD=password')
cursor = cnxn.cursor()
cursor.execute("""
SELECT
CounterID,
MachineName,
CONCAT(ObjectName, '' ,CounterName) AS 'CounterName',
ISNULL(InstanceName, '') AS 'Instances'
FROM dbo.CounterDetails
""")
rows = cursor.fetchall()
objects_list = []
for row in rows:
d = collections.OrderedDict()
d['CounterID'] = row.CounterID
d['MachineName'] = row.MachineName
d['CounterName'] = row.CounterName
d['Instances'] = row.Instances
objects_list.append(d)
j = json.dumps(objects_list)
print j