I am using SQLite.swift and I want to list all tables in my database.
I tried the following SQL statements.
database.execute("SELECT * FROM sqlite_master WHERE type='table'")
I only get empty list.
database.execute does not return a value, it only executes the statement on the database. You can see it does not return in the source code:
// MARK: - Execute
/// Executes a batch of SQL statements.
///
/// - Parameter SQL: A batch of zero or more semicolon-separated SQL
/// statements.
///
/// - Throws: `Result.Error` if query execution fails.
public func execute(_ SQL: String) throws {
_ = try sync { try self.check(sqlite3_exec(self.handle, SQL, nil, nil, nil)) }
}
Instead of execute, you can using the selection query DSL defined in the documentation here