/* Init * * Creates a sqlite database object * * */ public static Database Init() { // We need make path to db file and create connection string SqlPath = Path.Combine(TShock.SavePath, "tshock.sqlite"); var Connection = new SqliteConnection(string.Format("uri=file://{0},Version=3", SqlPath)); var Database = new Database(Connection); //Database.InitPlayersList(); return Database; }
/* SetupDB * * Initialize database * * */ private void SetupDB() { DB = Database.Init(); // Our tables in db SqlTable UserKills = new SqlTable("user_kills_stats", new SqlColumn("id", MySqlDbType.Int32) { Primary = true, AutoIncrement = true }, new SqlColumn("user_id", MySqlDbType.Text), new SqlColumn("mob_id", MySqlDbType.Text), new SqlColumn("kills", MySqlDbType.Int32)); SqlTable UserStats = new SqlTable("user_stats", new SqlColumn("id", MySqlDbType.Int32) { Primary = true, AutoIncrement = true }, new SqlColumn("user_id", MySqlDbType.Text) { Unique = true }, new SqlColumn("tiles_destroyed", MySqlDbType.Int32), new SqlColumn("tiles_placed", MySqlDbType.Int32), new SqlColumn("deaths", MySqlDbType.Int32)); DB.EnsureExists(UserKills, UserStats); }
/* Constructor * */ public SPluginApi(Rest Rest, Database DB) { this.Rest = Rest; this.DB = DB; }