hytos / DTI_PID / ID2PSN / AppSQLiteDatabase.cs @ 0ff2a9f1
이력 | 보기 | 이력해설 | 다운로드 (1.99 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Data; |
6 |
using System.Data.Common; |
7 |
using System.Data.SQLite; |
8 |
using System.Globalization; |
9 |
using System.Data.SqlClient; |
10 | |
11 |
namespace ID2PSN |
12 |
{ |
13 |
class AppSQLiteDatabase : AbstractDatabase<SQLiteConnection , SQLiteCommand , SQLiteDataAdapter> |
14 |
{ |
15 |
public string FilePath{get;set;} |
16 | |
17 |
/// <summary> |
18 |
/// sqlite connection string |
19 |
/// </summary> |
20 |
/// <author>humkyung</author> |
21 |
/// <date>2019.02.10</date> |
22 |
/// <returns></returns> |
23 |
protected override string GetConnectionString() |
24 |
{ |
25 |
return string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", this.FilePath); |
26 |
} |
27 | |
28 |
/// <summary> |
29 |
/// get table name list |
30 |
/// </summary> |
31 |
/// <author>humkyung</author> |
32 |
/// <date>2021.11.04</date> |
33 |
/// <param name="sTableName"></param> |
34 |
/// <returns></returns> |
35 |
public override List<string> GetTableNames() |
36 |
{ |
37 |
List<string> res = new List<string> { }; |
38 |
{ |
39 |
var query = "SELECT NAME FROM sqlite_master WHERE type='table'"; |
40 |
using (var ds = ExecuteDataSet(GetSqlStringCommand(query))) |
41 |
{ |
42 |
foreach (DataRow dr in ds.Tables[0].Rows) |
43 |
{ |
44 |
res.Add(dr["NAME"].ToString()); |
45 |
} |
46 |
} |
47 |
} |
48 | |
49 |
return res; |
50 |
} |
51 | |
52 |
public override List<string> GetColumnNames(string TableName) |
53 |
{ |
54 |
List<string> res = new List<string> { }; |
55 |
{ |
56 |
var query = "PRAGMA table_info('" + TableName + "')"; |
57 |
using (var ds = ExecuteDataSet(GetSqlStringCommand(query))) |
58 |
{ |
59 |
foreach (DataRow dr in ds.Tables[0].Rows) |
60 |
{ |
61 |
res.Add(dr["NAME"].ToString()); |
62 |
} |
63 |
} |
64 |
} |
65 | |
66 |
return res; |
67 |
} |
68 |
} |
69 |
} |