From a2d48a8c152c5ddad5f78a11703ae26bb93d536a Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Sat, 29 May 2021 22:48:48 -0700 Subject: [PATCH] Add a function to return the path of a Connection (#963) --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index f62ed41..a14d8ea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -537,6 +537,16 @@ impl Connection { .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 /// named parameter(s). ///