From b8ba273e0eca549cc293fe0e82f6859c6e7b53b2 Mon Sep 17 00:00:00 2001 From: pi-ux-ce Date: Mon, 9 Jun 2025 22:54:11 +0000 Subject: [PATCH] download the database if not present --- Program.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Program.cs b/Program.cs index 41d5425..47e8a56 100644 --- a/Program.cs +++ b/Program.cs @@ -2,6 +2,7 @@ using System.ComponentModel; using System.Diagnostics; using System.Data.SQLite; +using System.Net; using System.Runtime.InteropServices; using static System.Net.Mime.MediaTypeNames; @@ -17,6 +18,17 @@ class Program { SQLiteConnection sqliteconn; + + if (!(File.Exists($"{FolderPath}/database.db"))) + { + Console.WriteLine("Creating database.db"); + using (var client = new WebClient()) + { + client.DownloadFile("https://gitea.tryton.geeraert.eu//pi-ux-ce/Simpsons_generator/raw/branch/main/database.db", $"{FolderPath}/database.db"); + } + + } + // Create a new database connection: var sqllitedatasource = $"Data Source={FolderPath}/database.db;Version=3;New=True;Compress=True;"; sqliteconn = new SQLiteConnection(sqllitedatasource);