-
Notifications
You must be signed in to change notification settings - Fork 227
Expand file tree
/
Copy pathDatabase.cs
More file actions
38 lines (32 loc) · 930 Bytes
/
Copy pathDatabase.cs
File metadata and controls
38 lines (32 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using Dapper;
using Microsoft.Data.Sqlite;
using System;
using System.Collections.Generic;
using System.Text;
namespace CodingTracker.urasylmaz1.Data
{
public class Database
{
private readonly string _connectionString;
public Database(string connectionString)
{
_connectionString = connectionString;
}
public void Initialize()
{
// using Dapper instead of raw ADO.NET for simplicity
using var connection =
new SqliteConnection(_connectionString);
string sql = @"
CREATE TABLE IF NOT EXISTS CodingSessions
(
Id INTEGER PRIMARY KEY AUTOINCREMENT,
StartTime TEXT,
EndTime TEXT,
Duration TEXT
);
";
connection.Execute(sql);
}
}
}