mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 18:39:07 +00:00
1.3.0b
- Minor changes - Fixed `css_players` - Probably fixed problems with taking actions with bots
This commit is contained in:
40
Database.cs
40
Database.cs
@@ -1,19 +1,31 @@
|
||||
using MySqlConnector;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MySqlConnector;
|
||||
|
||||
namespace CS2_SimpleAdmin;
|
||||
public class Database
|
||||
namespace CS2_SimpleAdmin
|
||||
{
|
||||
private readonly string _dbConnectionString;
|
||||
|
||||
public Database(string dbConnectionString)
|
||||
public class Database
|
||||
{
|
||||
_dbConnectionString = dbConnectionString;
|
||||
}
|
||||
private readonly string _dbConnectionString;
|
||||
|
||||
public MySqlConnection GetConnection()
|
||||
{
|
||||
var connection = new MySqlConnection(_dbConnectionString);
|
||||
connection.Open();
|
||||
return connection;
|
||||
public Database(string dbConnectionString)
|
||||
{
|
||||
_dbConnectionString = dbConnectionString;
|
||||
}
|
||||
|
||||
public async Task<MySqlConnection> GetConnection()
|
||||
{
|
||||
try
|
||||
{
|
||||
var connection = new MySqlConnection(_dbConnectionString);
|
||||
await connection.OpenAsync();
|
||||
return connection;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (CS2_SimpleAdmin._logger != null)
|
||||
CS2_SimpleAdmin._logger.LogCritical("Unable to connect to database");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user