mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-18 10:43:23 +00:00
test
test
This commit is contained in:
31
Database/Database.cs
Normal file
31
Database/Database.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MySqlConnector;
|
||||
|
||||
namespace CS2_SimpleAdmin
|
||||
{
|
||||
public class Database
|
||||
{
|
||||
private readonly string _dbConnectionString;
|
||||
|
||||
public Database(string dbConnectionString)
|
||||
{
|
||||
_dbConnectionString = dbConnectionString;
|
||||
}
|
||||
|
||||
public async Task<MySqlConnection> GetConnectionAsync()
|
||||
{
|
||||
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