hytos / DTI_PID / ID2PSN / AppSQLiteDatabase.cs @ e835aef5
이력 | 보기 | 이력해설 | 다운로드 (2.68 KB)
1 | 23a96301 | humkyung | 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 | 0ff2a9f1 | LJIYEON | |
52 | 1d46fca7 | LJIYEON | |
53 | public override List<string> GetCommonTableNames() |
||
54 | { |
||
55 | List<string> res = new List<string> { }; |
||
56 | { |
||
57 | string query = "SELECT T.name AS table_name, C.name AS column_name" + |
||
58 | "FROM ARS_COMMON.sys.tables AS T INNER JOIN ARS_COMMON.sys.columns AS C ON T.object_id = C.object_id WHERE T.name = 'PSN_REVISION'"; |
||
59 | using (var ds = ExecuteDataSet(GetSqlStringCommand(query))) |
||
60 | { |
||
61 | foreach (DataRow dr in ds.Tables[0].Rows) |
||
62 | { |
||
63 | res.Add(dr["column_name"].ToString()); |
||
64 | } |
||
65 | } |
||
66 | } |
||
67 | |||
68 | return res; |
||
69 | } |
||
70 | |||
71 | 0ff2a9f1 | LJIYEON | public override List<string> GetColumnNames(string TableName) |
72 | { |
||
73 | List<string> res = new List<string> { }; |
||
74 | { |
||
75 | var query = "PRAGMA table_info('" + TableName + "')"; |
||
76 | using (var ds = ExecuteDataSet(GetSqlStringCommand(query))) |
||
77 | { |
||
78 | foreach (DataRow dr in ds.Tables[0].Rows) |
||
79 | { |
||
80 | res.Add(dr["NAME"].ToString()); |
||
81 | } |
||
82 | } |
||
83 | } |
||
84 | |||
85 | return res; |
||
86 | } |
||
87 | 23a96301 | humkyung | } |
88 | } |