using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NeshinaPolina2111
{
    internal class DB
    {
        private static DB instance;
        private MySqlConnection connection;
            private string connectionString = "server=git.pgk.alspio.com; port=3306; username=ISP41_Neshina; password=ISP41_Neshina; database=ISP41_Neshina_Dem2011; Sslmode=none; Charset=utf8mb4";

        private DB() {
          connection = new MySqlConnection(connectionString);
            OpenConnection();
        }

        public static DB GetInstance()
        {
            if (instance == null)
                instance = new DB();
            return instance;
        }

        public void OpenConnection()
        {
            if(connection.State == System.Data.ConnectionState.Closed)
                connection.Open();
        }

        public MySqlConnection GetConnection() => connection;
    }
}
