dbFilePath gets the file path of the SQLite database. It returns the empty string if the database is in-memory.
(ctx context.Context)
| 288 | // dbFilePath gets the file path of the SQLite database. |
| 289 | // It returns the empty string if the database is in-memory. |
| 290 | func (c *connection) dbFilePath(ctx context.Context) (string, error) { |
| 291 | var file string |
| 292 | err := c.db.QueryRowContext(ctx, `SELECT file FROM pragma_database_list WHERE name = 'main';`).Scan(&file) |
| 293 | if err != nil { |
| 294 | return "", err |
| 295 | } |
| 296 | if file == "" || file == ":memory:" || file == "file::memory:" { |
| 297 | return "", nil |
| 298 | } |
| 299 | return file, nil |
| 300 | } |