import MySQLdb, sys, configparser, time
from main_config import main_Config

def delete_project(project):

#    config=configparser.ConfigParser()
#    config.read('main.ini')
#    mysql_id=config['settings']["id"]
#    mysql_pass=config['settings']["pass"]
    mysql_id, mysql_pass, projects, root_path, using_os = main_Config()

    time.sleep(0.2)

    mysql_delete_project(project, mysql_id, mysql_pass)


def mysql_delete_project(project, mysql_id, mysql_pass):
    try:
        conn=MySQLdb.connect(db=project, user=mysql_id, passwd=mysql_pass, charset="utf8mb4")
        cursor=conn.cursor()

        sql="drop database " + project
        cursor.execute(sql)

        conn.commit()
        cursor.close()
        conn.close()

        #print("テーブル作成OK")

    except Exception as e:
        print(e)
