adhcount.py 476 B

123456789101112131415161718192021
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import sys, os
  4. import MySQLdb
  5. connection = MySQLdb.connect(host = "localhost", user = "user", passwd = "password", db = "dolibarr_database")
  6. cursor = connection.cursor()
  7. cursor.execute("select count(*) from llx_adherent where statut = '1'")
  8. row = cursor.fetchone()
  9. nbadherents = open('/path/to/your/web/directory/nbadherents','w')
  10. nbadherents.write(str(row[0]))
  11. nbadherents.close()
  12. cursor.close()
  13. connection.close()
  14. sys.exit()