Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide helper for SQLite #659

Open
hadley opened this issue Dec 7, 2023 · 1 comment
Open

Provide helper for SQLite #659

hadley opened this issue Dec 7, 2023 · 1 comment
Labels
feature a feature request or enhancement sqlite

Comments

@hadley
Copy link
Member

hadley commented Dec 7, 2023

Supported arguments:

  Database (string)     name of SQLite2/3 database file; default empty
  PWD (string)          password when built with SEE support; default empty
  Timeout (integer)     lock time out in milliseconds; default 100000
  StepAPI (boolean)     if true, use sqlite[3]_step et.al.; default false
  NoTXN (boolean)       if true, only pretend transactions; default false
  NoWCHAR (boolean)     if true, don't support WCHAR types for character
                        data; default false
  NoCreat (boolean)     if true and database file doesn't exist, don't
                        create it automatically; default false, unsupported
                        for SQLite2
  LongNames (boolean)   if true, don't shorten column names; default false
  ShortNames (boolean)  if true, enforce short column names; default false
  SyncPragma (string)   value for PRAGMA SYNCHRONOUS; default empty
  FKSupport (boolean)   if true, support SQLite3 foreign key constraints;
                        default false
  JournalMode (string)  value for PRAGMA JOURNAL_MODE; default empty
  OEMCP (boolean)       Win32 only: if true, translate strings from/to
                        UTF8 to current code page; default false
  BigInt (boolean)      if true, force integer columns to SQL_BIGINT;
                        default false
  JDConv (boolean)      if true, use SQLite3 julian day representation for
                        SQL_TIME, SQL_TIMESTAMP, SQL_DATE types; default false
  TraceFile (string)    name of file to write SQLite traces to; default empty
  AttachAs (string)     SQLite3 only: comma separated names to be the attach
                        names to the current database file; default empty
  ILike (boolean)       SQLite3 only: if true, treat ILIKE as LIKE in SQL
                        to mimic PostgreSQL syntax; default false 
@hadley
Copy link
Member Author

hadley commented Jan 12, 2024

sqlite_driver_default <- function() {
  # Assume that if SQLite driver is setup up it's correct
  drivers <- unique(odbcListDrivers()$name)
  if ("SQLite" %in% drivers) {
    return("SQLite")
  }
  
  if (Sys.info()["sysname"] == "Darwin") {
    if (Sys.which("brew") == "") {
      abort("Homebrew is not installed")
    }
    
    paths <- system("brew list sqliteodbc", intern = TRUE)
    if (attr(paths, "status") != 0) {
      abort("Failed to list sqliteodbc brew file")
    }
    paths[basename(paths) == "libsqlite3odbc.dylib"]
  } else {
    abort("Autodiscovery currently only supported on macOS")
  }
}

@hadley hadley added feature a feature request or enhancement sqlite labels Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement sqlite
Projects
None yet
Development

No branches or pull requests

1 participant