summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore65
-rw-r--r--main.py29
2 files changed, 94 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..521e6e3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,65 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+venv/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*,cover
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# .idea
+.idea
+
+# project stuff
+info.json
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()