()
| 149 | } |
| 150 | |
| 151 | async getTables(): Promise<string[]> { |
| 152 | try { |
| 153 | const db = this.getConnection(); |
| 154 | if (!db) { |
| 155 | return Promise.reject('Cannot connect to database') |
| 156 | } |
| 157 | |
| 158 | return new Promise<string[]>((resolve, reject) => { |
| 159 | const query = `SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name`; |
| 160 | |
| 161 | db.all(query, (err, rows: any[]) => { |
| 162 | if (err) { |
| 163 | reportError(`SQLite get tables error: ${err}`); |
| 164 | reject(err); |
| 165 | return; |
| 166 | } |
| 167 | |
| 168 | const tableNames = rows.map(row => row.name); |
| 169 | resolve(tableNames); |
| 170 | }); |
| 171 | }); |
| 172 | } catch (err) { |
| 173 | reportError(`SQLite get tables error: ${err}`); |
| 174 | return []; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | async getColumns(table: string): Promise<Column[]> { |
| 179 | try { |
nothing calls this directly
no test coverage detected