configure-phpfin.py 764 Bytes
Newer Older
Mayoro Diagne's avatar
Mayoro Diagne committed
1 2 3 4 5 6
# -*- coding: utf-8 -*-
import sys
import os
import MySQLdb

def setup(args):
7 8
   renamed, mysql_host,  mysql_user, mysql_password, mysql_database, base_url, htdocs = args
   #base_url, htdocs, renamed, mysql_user, mysql_password, mysql_database, mysql_host = args
Mayoro Diagne's avatar
Mayoro Diagne committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
   sql_file = os.path.join(htdocs, "scripts/phpfin.sql")
   try:
       conn = MySQLdb.connect (host = mysql_host,
                             user = mysql_user,
                             passwd = mysql_password,
                             db = mysql_database)
       cursor = conn.cursor ()
       with open(sql_file, 'r') as f:
         sql_script = f.read()
         cursor.execute(sql_script)
       conn.close()
   except:
       return

if __name__ == '__main__':
   setup(sys.argv[1:])