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

namespace NeshinaDem3
{
    internal class DB
    {
        private static DB instance;
        private MySqlConnection connection;
        //ПОДКЧЛЮЧЕНИЕ
        private readonly string connectionString =
            "server=192.168.201.207;port=3306;username=ISP41_Neshina;password=ISP41_Neshina;database=ISP41_Neshina_dem2;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 == ConnectionState.Closed)
                connection.Open();
        }

        public MySqlConnection GetConnection() => connection;
    }
}
