1234567891011121314151617181920212223242526 |
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- # https://gitorious.org/dolicount/
- import sys, os, json
- import MySQLdb
- info = '/path/to/your/web/directory/isp.json'
- data = json.loads(open(info).read())
- connection = MySQLdb.connect(host = "localhost", user = "user", passwd = "password", db = "dolibarr_database")
- cursor = connection.cursor()
- cursor.execute("SELECT COUNT(*) FROM llx_adherent WHERE statut = '1'")
- row = cursor.fetchone()
- data['memberCount'] = row[0]
- cursor.execute("SELECT COUNT(*) FROM llx_societe WHERE status = '1' AND client='1'")
- row = cursor.fetchone()
- data['subscriberCount'] = row[0]
- with open(info, 'w') as outfile:
- json.dump(data, outfile)
- cursor.close()
- connection.close()
- sys.exit()
|