2

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.

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.