/
NLObP
/
AAEmu
Обзор
Документация
Войти
/
NLObP
/
AAEmu
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
AAEmu.Game/Utils/DB/SQLite.cs
34 строки
986 B
Roger Barreto
Code Improvements + Integration Test Fix + Log -> Logger (#747)
06 окт 2023, 20:53
Не верифицирован
06 окт 2023, 20:53
8ca858e
Код
Авторство
О чём код?
using System; using System.IO; using AAEmu.Commons.IO; using Microsoft.Data.Sqlite; using NLog; namespace AAEmu.Game.Utils.DB; public static class SQLite { private static Logger Logger { get; } = LogManager.GetCurrentClassLogger(); public static SqliteConnection CreateConnection(string directory = "Data", string sqlite = "compact.sqlite3") { var dbPath = Path.Combine(FileManager.AppPath, directory, sqlite); if (!File.Exists(dbPath)) { Logger.Fatal("Server database does not exist: {0} !", dbPath); throw new FileNotFoundException("Server database does not exist: " + dbPath); } var connection = new SqliteConnection($"Data Source=file:{dbPath}; Mode=ReadOnly"); try { connection.Open(); } catch (Exception e) { Logger.Error(e, "Error on SQLite connect: {0}", e.Message); throw; } return connection; } }