summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rw-r--r--main.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..60b12c0
--- /dev/null
+++ b/main.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import os
+import json
+import mysql.connector
+
+with open ('/webspace/path/info.json', 'w') as f:
+ cnx = mysql.connector.connect(user='user', password="pass", database='db')
+ cursor = cnx.cursor()
+ cursor.execute("SELECT node FROM caps_features GROUP BY subnode;")
+
+ result = dict()
+ for client in cursor:
+ client = client[0]
+ if client not in result.keys():
+ result[client] = 1
+ else:
+ result[client] += 1
+
+ cursor.close()
+ cnx.close()
+
+ try:
+ f.write(json.dumps(result, indent=4, sort_keys=True))
+ except FileNotFoundError:
+ pass
+
+ f.close()