Skip to content

dbExistsTable(conn, Id(schema = "INFORMATION_SCHEMA", table = "TABLES")) throws error (should return FALSE?) #498

Closed

Description

@kjellpk

dbExistsTable borks when conn is a SQLiteConnection and name is an Id with schema = "INFORMATION_SCHEMA" and table = "TABLES". I was expecting it to return FALSE.

library(DBI)
conn <- dbConnect(RSQLite::SQLite(), ":memory:")
dbExistsTable(conn, Id(schema = "INFORMATION_SCHEMA", table = "TABLES"))
# Error: no such table: INFORMATION_SCHEMA.sqlite_master
dbDisconnect(conn)

Activity

  1. krlmlr commented on Mar 3, 2024

    @krlmlr
    Member

    Thanks, good catch. I suspect we want to check if the schema exists first. Would you like to contribute?

  2. kjellpk commented on Mar 4, 2024

    @kjellpk
    ContributorAuthor

    Happy to help.

    After a bit of Googling, my understanding is that schemas in SQLite (here I am using the word schema to mean the part before the . in schema.table) are the names of the ATTACHed databases. It seems like the only way there could ever be a schema other than "main" would be if ATTACH is used in a SQL statement.

    The following code returns a character vector of the attached databases:

    dbGetQuery(conn, "SELECT name FROM pragma_database_list;")$name

    I'll see if I can find a good place to put a check.

  3. github-actions commented on Apr 2, 2025

    @github-actions
    Contributor

    This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

  4. locked and limited conversation to collaborators on Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions