# -*- coding: utf-8 -*-
import mysql.connector


class DatabaseApiMysql:
    def __init__(self):
        self.cnx = None
        self.auto_update = False
        self.cursor = None
        print("CREATE link to DATABASE MYSQL")

    def open(self, host, database, user, password, port):
        config = {
            'host': host,
            'database': database,
            'user': user,
            'password': password,
            'port': port
        }

        self.cnx = mysql.connector.connect(**config)
        self.cursor = self.cnx.cursor()

    def commit(self):
        if not self.auto_update:
            self.cnx.commit()

    def close(self):
        pass
