Add a function to return the path of a Connection (#963)

This commit is contained in:
Thom Chiovoloni 2021-05-29 22:48:48 -07:00 committed by GitHub
parent 5511a12e57
commit a2d48a8c15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -537,6 +537,16 @@ impl Connection {
.and_then(|mut stmt| stmt.check_no_tail().and_then(|_| stmt.execute(params))) .and_then(|mut stmt| stmt.check_no_tail().and_then(|_| stmt.execute(params)))
} }
/// Returns the path to the database file, if one exists and is known.
///
/// Note that in some cases [PRAGMA
/// database_list](https://sqlite.org/pragma.html#pragma_database_list) is
/// likely to be more robust.
#[inline]
pub fn path(&self) -> Option<&Path> {
self.path.as_deref()
}
/// Convenience method to prepare and execute a single SQL statement with /// Convenience method to prepare and execute a single SQL statement with
/// named parameter(s). /// named parameter(s).
/// ///