Package RSQLite. February 19, 2015



Similar documents
Package RPostgreSQL. February 19, 2015

Computing with large data sets

Package TSfame. February 15, 2013

Using Databases in R

Session 6: ROracle. <Insert Picture Here> Mark Hornick, Director, Oracle Advanced Analytics Development Oracle Advanced Analytics

Package sjdbc. R topics documented: February 20, 2015

Package uptimerobot. October 22, 2015

Package retrosheet. April 13, 2015

Lecture 25: Database Notes

SAP BusinessObjects Business Intelligence platform Document Version: 4.1 Support Package Information Design Tool User Guide

Package packrat. R topics documented: March 28, Type Package

Package OECD. R topics documented: January 17, Type Package Title Search and Extract Data from the OECD Version 0.2.

Package HadoopStreaming

The Saves Package. an approximate benchmark of performance issues while loading datasets. Gergely Daróczi

SnapLogic Salesforce Snap Reference

Package searchconsoler

Package fimport. February 19, 2015

Raima Database Manager Version 14.0 In-memory Database Engine

Package RCassandra. R topics documented: February 19, Version Title R/Cassandra interface

Interacting with local and remote data repositories using the stashr package

Package urltools. October 11, 2015

Jet Data Manager 2012 User Guide

Package GEOquery. August 18, 2015

IceWarp to IceWarp Server Migration

Package hive. July 3, 2015

Package hoarder. June 30, 2015

Package cgdsr. August 27, 2015

Integrating VoltDB with Hadoop

SQL Server An Overview

Package PKI. July 28, 2015

Reading and writing files

Package R4CDISC. September 5, 2015

ODBC Driver Version 4 Manual

Gladinet Cloud Backup V3.0 User Guide

Time Series Database Interface: R MySQL (TSMySQL)

MySQL for Beginners Ed 3

Wave Analytics External Data API Developer Guide

org.rn.eg.db December 16, 2015 org.rn.egaccnum is an R object that contains mappings between Entrez Gene identifiers and GenBank accession numbers.

Simba Apache Cassandra ODBC Driver

Package TimeWarp. R topics documented: April 1, 2015

rm(list=ls()) library(sqldf) system.time({large = read.csv.sql("large.csv")}) # seconds, 4.23GB of memory used by R

SAP BusinessObjects Business Intelligence platform Document Version: 4.1 Support Package Information Design Tool User Guide

"SQL Database Professional " module PRINTED MANUAL

How to Set Up a Shared SQL Express Database with ManagePro 7 Standard version

Instant SQL Programming

Concepts of Database Management Seventh Edition. Chapter 7 DBMS Functions

Package RIGHT. March 30, 2015

CA DLP. Stored Data Integration Guide. Release rd Edition

Refresh Web Query Synonym

Physical Design. Meeting the needs of the users is the gold standard against which we measure our success in creating a database.

Advanced Tutorials. The Dark Side of the Transparent Moon

Package hive. January 10, 2011

TIBCO ActiveMatrix BusinessWorks Plug-in for Big Data User s Guide

Oracle EXAM - 1Z Oracle Database 11g Release 2: SQL Tuning. Buy Full Product.

ER/Studio 8.0 New Features Guide

Dataframes. Lecture 8. Nicholas Christian BIOST 2094 Spring 2011

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

Data Domain Profiling and Data Masking for Hadoop

Portal Connector Fields and Widgets Technical Documentation

Using IRDB in a Dot Net Project

Your Best Next Business Solution Big Data In R 24/3/2010

Classes for record linkage of big data sets

New Features... 1 Installation... 3 Upgrade Changes... 3 Fixed Limitations... 4 Known Limitations... 5 Informatica Global Customer Support...

DBMS / Business Intelligence, SQL Server

The release notes provide details of enhancements and features in Cloudera ODBC Driver for Impala , as well as the version history.

Chart of Accounts (COA) Validation Service. 6/11/2012 University at California, Berkeley IS&T, Application Services

National Fire Incident Reporting System (NFIRS 5.0) Configuration Tool User's Guide

Package bigrf. February 19, 2015

Migrating from Sybase to SQL Server

Configuring Apache Derby for Performance and Durability Olav Sandstå

Backing Up TestTrack Native Project Databases

NDSR Utilities. Creating Backup Files. Chapter 9

Database Administration with MySQL

ANDROID APPS DEVELOPMENT FOR MOBILE GAME

1 Introduction FrontBase is a high performance, scalable, SQL 92 compliant relational database server created in the for universal deployment.

Using Apache Derby in the real world

Data Storage STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley

Distributed R for Big Data

Chapter 6: Physical Database Design and Performance. Database Development Process. Physical Design Process. Physical Database Design

ODBC Chapter,First Edition

Restore and Recovery Tasks. Copyright 2009, Oracle. All rights reserved.

Oracle Essbase Integration Services. Readme. Release

Spectrum Technology Platform. Version 9.0. Spectrum Spatial Administration Guide

Package AzureML. August 15, 2015

Package benford.analysis

Java DB Performance. Olav Sandstå Sun Microsystems, Trondheim, Norway Submission ID: 860

SQL Server Replication Guide

Package date. R topics documented: February 19, Version Title Functions for handling dates. Description Functions for handling dates.

Informatica Corporation Proactive Monitoring for PowerCenter Operations Version 3.0 Release Notes May 2014

Using Object Database db4o as Storage Provider in Voldemort

Data Access Guide. BusinessObjects 11. Windows and UNIX

TIBCO Spotfire Metrics Modeler User s Guide. Software Release 6.0 November 2013

Package tagcloud. R topics documented: July 3, 2015

Database Studio is the new tool to administrate SAP MaxDB database instances as of version 7.5.

Real-time Data Replication

Wave Analytics Data Integration

AIMMS Function Reference - Arithmetic Functions

Transcription:

Version 1.0.0 Title SQLite Interface for R Package RSQLite February 19, 2015 This package embeds the SQLite database engine in R and provides an interface compliant with the DBI package. The source for the SQLite engine (version 3.8.6) is included. Depends R (>= 2.10.0), DBI (>= 0.3.1), methods Suggests testthat License LGPL (>= 2) URL https://github.com/rstats-db/rsqlite BugReports https://github.com/rstats-db/rsqlite/issues Collate 'ConnectionExtensions.R' 'Connection.R' 'Driver.R' 'Connect.R' 'ConnectionRead.R' 'ConnectionTransactions.R' 'ConnectionWrite.R' 'Constants.R' 'Escaping.R' 'Result.R' 'Object.R' 'Summary.R' 'Utils.R' 'datasetsdb.r' 'dbgetinfo.r' 'extensions.r' 'zzz.r' Author Hadley Wickham [aut, cre], David A. James [aut], Seth Falcon [aut], SQLite Authors [ctb] (for the included SQLite sources), Liam Healy [ctb] (for the include SQLite extensions), RStudio [cph] Maintainer Hadley Wickham <hadley@rstudio.com> NeedsCompilation yes Repository CRAN Date/Publication 2014-10-25 01:58:48 R topics documented: datasetsdb.......................................... 2 dbconnect,sqlitedriver-method.............................. 3 dbdatatype,sqliteconnection-method.......................... 4 1

2 datasetsdb dbexiststable,sqliteconnection,character-method.................... 5 dbgetinfo.......................................... 5 dbisvalid.......................................... 6 dblistfields,sqliteconnection,character-method..................... 7 dblisttables,sqliteconnection-method.......................... 7 dbreadtable,sqliteconnection,character-method.................... 8 dbremovetable,sqliteconnection,character-method................... 9 dbsendpreparedquery................................... 9 dbunloaddriver,sqlitedriver-method........................... 10 dbwritetable,sqliteconnection,character,data.frame-method.............. 10 initextension........................................ 12 query............................................ 13 sqlite-meta.......................................... 14 SQLiteConnection-class.................................. 15 sqlitecopydatabase..................................... 16 SQLiteDriver-class..................................... 17 sqlitequickcolumn..................................... 18 SQLiteResult-class..................................... 19 transactions......................................... 19 Index 21 datasetsdb A sample sqlite database. This database is bundled with the package, and contains all data frames in the datasets package. datasetsdb() db <- datasetsdb() dblisttables(db) dbreadtable(db, "CO2") dbgetquery(db, "SELECT * FROM CO2 WHERE conc < 100") dbdisconnect(db)

dbconnect,sqlitedriver-method 3 dbconnect,sqlitedriver-method Connect to/disconnect from a SQLite database. Connect to/disconnect from a SQLite database. ## S4 method for signature SQLiteDriver dbconnect(drv, dbname = "", loadable.extensions = TRUE, cache_size = NULL, synchronous = "off", flags = SQLITE_RWC, vfs = NULL) ## S4 method for signature SQLiteConnection dbconnect(drv) ## S4 method for signature SQLiteConnection dbdisconnect(conn) drv,conn dbname An objected generated by SQLite, or an existing SQLiteConnection. If an connection, the connection will be cloned. The path to the database file. There are two special values: "": creates a temporary on-disk database The file will be deleted when the connection is closed. ":memory:": create a temporary in-memory database. loadable.extensions When TRUE (default) SQLite3 loadable extensions are enabled. value to FALSE prevents extensions from being loaded. cache_size Setting this Advanced option. A positive integer to change the maximum number of disk pages that SQLite holds in memory (SQLite s default is 2000 pages). See http: //www.sqlite.org/pragma.html#pragma_cache_size for details. synchronous Advanced options. Possible values for synchronous are "off" (the default), "normal", or "full". Users have reported significant speed ups using sychronous = "off", and the SQLite documentation itself implies considerable improved performance at the very modest risk of database corruption in the unlikely case of the operating system (not the R application) crashing. See http://www.sqlite.org/ pragma.html#pragma_synchronous for details. flags SQLITE_RWC: open the database in read/write mode and create the database file if it does not already exist; SQLITE_RW: open the database in read/write mode. Raise an error if the file does not already exist; SQLITE_RO: open the database in read only mode. Raise an error if the file does not already exist

4 dbdatatype,sqliteconnection-method vfs Select the SQLite3 OS interface. See http://www.sqlite.org/vfs.html for details. Allowed values are "unix-posix", "unix-unix-afp", "unix-unix-flock", "unix-dotfile", and "unix-none". # Create temporary in-memory db tmp <- dbconnect(sqlite(), ":memory:") summary(tmp) dbdisconnect(tmp) # Create temporary on-disk db with bigger cache and safer synchronisation tmp <- dbconnect(sqlite(), "", cache_size = 5000, synchronous = "full") summary(tmp) dbdisconnect(tmp) dbdatatype,sqliteconnection-method Determine the SQL Data Type of an R object. This method is a straight-forward implementation of the corresponding generic function. ## S4 method for signature SQLiteConnection dbdatatype(dbobj, obj,...) ## S4 method for signature SQLiteDriver dbdatatype(dbobj, obj,...) dbobj obj a SQLiteDriver object, an R object whose SQL type we want to determine.... Needed for compatibility with generic. Otherwise ignored. data(quakes) drv <- SQLite() sapply(quakes, function(x) dbdatatype(drv, x)) dbdatatype(drv, 1) dbdatatype(drv, as.integer(1)) dbdatatype(drv, "1") dbdatatype(drv, chartoraw("1"))

dbexiststable,sqliteconnection,character-method 5 dbexiststable,sqliteconnection,character-method Does the table exist? Does the table exist? ## S4 method for signature SQLiteConnection,character dbexiststable(conn, name) conn name An existing SQLiteConnection String, name of table. Match is case insensitive. dbgetinfo Get metadata about a database object. Get metadata about a database object. ## S4 method for signature SQLiteDriver dbgetinfo(dbobj) ## S4 method for signature SQLiteConnection dbgetinfo(dbobj) ## S4 method for signature SQLiteResult dbgetinfo(dbobj) dbobj An object of class SQLiteDriver, SQLiteConnection or SQLiteResult

6 dbisvalid dbgetinfo(sqlite()) con <- dbconnect(sqlite()) dbgetinfo(con) dbwritetable(con, "mtcars", mtcars) rs <- dbsendquery(con, "SELECT * FROM mtcars") dbgetinfo(rs) dbfetch(rs, 1) dbgetinfo(rs) dbclearresult(rs) dbdisconnect(con) dbisvalid Check whether an SQLite object is valid or not. Support function that verifies that the holding a reference to a foreign object is still valid for communicating with the RDBMS ## S4 method for signature SQLiteDriver dbisvalid(dbobj) ## S4 method for signature SQLiteConnection dbisvalid(dbobj) ## S4 method for signature SQLiteResult dbisvalid(dbobj) isidcurrent(obj) dbobj,obj A driver, connection or result. Value A logical scalar.

dblistfields,sqliteconnection,character-method 7 dbisvalid(sqlite()) con <- dbconnect(sqlite()) dbisvalid(con) dbdisconnect(con) dbisvalid(con) dblistfields,sqliteconnection,character-method List fields in specified table. List fields in specified table. ## S4 method for signature SQLiteConnection,character dblistfields(conn, name) conn name An existing SQLiteConnection a length 1 character vector giving the name of a table. con <- dbconnect(sqlite()) dbwritetable(con, "iris", iris) dblistfields(con, "iris") dbdisconnect(con) dblisttables,sqliteconnection-method List available SQLite tables. List available SQLite tables. ## S4 method for signature SQLiteConnection dblisttables(conn)

8 dbreadtable,sqliteconnection,character-method conn An existing SQLiteConnection dbreadtable,sqliteconnection,character-method Convenience functions for importing/exporting DBMS tables These functions mimic their R/S-Plus counterpart get, assign, exists, remove, and objects, except that they generate code that gets remotely executed in a database engine. ## S4 method for signature SQLiteConnection,character dbreadtable(conn, name, row.names, check.names = TRUE, select.cols = "*") conn name row.names check.names select.cols a SQLiteConnection object, produced by dbconnect a character string specifying a table name. SQLite table names are not case sensitive, e.g., table names ABC and abc are considered equal. A string or an index specifying the column in the DBMS table to use as row.names in the output data.frame. Defaults to using the row_names column if present. Set to NULL to never use row names. If TRUE, the default, column names will be converted to valid R identifiers. A SQL statement (in the form of a character vector of length 1) giving the columns to select. E.g. "*" selects all columns, "x,y,z" selects three columns named as listed. Value A data.frame in the case of dbreadtable; otherwise a logical indicating whether the operation was successful. Note Note that the data.frame returned by dbreadtable only has primitive data, e.g., it does not coerce character data to factors.

dbremovetable,sqliteconnection,character-method 9 con <- dbconnect(sqlite()) dbwritetable(con, "mtcars", mtcars) dbreadtable(con, "mtcars") # Supress row names dbreadtable(con, "mtcars", row.names = FALSE) dbdisconnect(con) dbremovetable,sqliteconnection,character-method Remove a table from the database. Executes the SQL DROP TABLE. ## S4 method for signature SQLiteConnection,character dbremovetable(conn, name) conn name An existing SQLiteConnection character vector of length 1 giving name of table to remove dbsendpreparedquery Generics for getting and sending prepared queries. Generics for getting and sending prepared queries. dbsendpreparedquery(conn, statement, bind.data,...) dbgetpreparedquery(conn, statement, bind.data,...) conn An DBIConnection object. statement A SQL string bind.data A data frame... Other arguments used by methods

10 dbwritetable,sqliteconnection,character,data.frame-method dbunloaddriver,sqlitedriver-method Unload SQLite driver. Unload SQLite driver. ## S4 method for signature SQLiteDriver dbunloaddriver(drv,...) drv Object created by SQLite... Ignored. Needed for compatibility with generic. Value A logical indicating whether the operation succeeded or not. ## Not run: db <- SQLite() dbunloaddriver(db) ## End(Not run) dbwritetable,sqliteconnection,character,data.frame-method Write a local data frame or file to the database. Write a local data frame or file to the database.

dbwritetable,sqliteconnection,character,data.frame-method 11 ## S4 method for signature SQLiteConnection,character,data.frame dbwritetable(conn, name, value, row.names = NA, overwrite = FALSE, append = FALSE, field.types = NULL) ## S4 method for signature SQLiteConnection,character,character dbwritetable(conn, name, value, field.types = NULL, overwrite = FALSE, append = FALSE, header = TRUE, colclasses = NA, row.names = FALSE, nrows = 50, sep = ",", eol = "\n", skip = 0) conn name value row.names overwrite append field.types header colclasses nrows sep eol a SQLiteConnection object, produced by dbconnect a character string specifying a table name. SQLite table names are not case sensitive, e.g., table names ABC and abc are considered equal. a data.frame (or coercible to data.frame) object or a file name (character). In the first case, the data.frame is written to a temporary file and then imported to SQLite; when value is a character, it is interpreted as a file name and its contents imported to SQLite. A logical specifying whether the row.names should be output to the output DBMS table; if TRUE, an extra field whose name will be whatever the R identifier "row.names" maps to the DBMS (see make.db.names). If NA will add rows names if they are characters, otherwise will ignore. a logical specifying whether to overwrite an existing table or not. Its default is FALSE. (See the BUGS section below) a logical specifying whether to append to an existing table in the DBMS. Its default is FALSE. character vector of named SQL field types where the names are the names of new table s columns. If missing, types inferred with dbdatatype). is a logical indicating whether the first data line (but see skip) has a header or not. If missing, it value is determined following read.table convention, namely, it is set to TRUE if and only if the first row has one fewer field that the number of columns. Character vector of R type names, used to override defaults when imputing classes from on-disk file. Number of rows to read to determine types. The field separator, defaults to,. The end-of-line delimiter, defaults to \n. skip number of lines to skip before reading the data. Defaults to 0.

12 initextension con <- dbconnect(sqlite()) dbwritetable(con, "mtcars", mtcars) dbreadtable(con, "mtcars") # A zero row data frame just creates a table definition. dbwritetable(con, "mtcars2", mtcars[0, ]) dbreadtable(con, "mtcars2") dbdisconnect(con) initextension Add useful extension functions. These extension functions are written by Liam Healy and made available through the SQLite website (http://www.sqlite.org/contrib). initextension(db) db A database to load these extensions. Available extension functions Math functions acos, acosh, asin, asinh, atan, atan2, atanh, atn2, ceil, cos, cosh, cot, coth, degrees, difference, exp, floor, log, log10, pi, power, radians, sign, sin, sinh, sqrt, square, tan, tanh String functions charindex, leftstr, ltrim, padc, padl, padr, proper, replace, replicate, reverse, rightstr, rtrim, strfilter, trim Aggregate functions stdev, variance, mode, median, lower_quartile, upper_quartile db <- dbconnect(sqlite()) initextension(db) dbwritetable(db, "mtcars", mtcars) dbgetquery(db, "SELECT stdev(mpg) FROM mtcars") sd(mtcars$mpg)

query 13 query Execute a SQL statement on a database connection To retrieve results a chunk at a time, use dbsendquery, dbfetch, then ClearResult. Alternatively, if you want all the results (and they ll fit in memory) use dbgetquery which sends, fetches and clears for you. ## S4 method for signature SQLiteConnection,character dbsendquery(conn, statement) ## S4 method for signature SQLiteConnection,character,data.frame dbsendpreparedquery(conn, statement, bind.data) ## S4 method for signature SQLiteResult dbfetch(res, n = 0) ## S4 method for signature SQLiteResult fetch(res, n = 0) ## S4 method for signature SQLiteResult dbclearresult(res,...) ## S4 method for signature SQLiteConnection dbclearresult(res,...) ## S4 method for signature SQLiteConnection dblistresults(conn,...) ## S4 method for signature SQLiteConnection,character dbgetquery(conn, statement) ## S4 method for signature SQLiteConnection,character,data.frame dbgetpreparedquery(conn, statement, bind.data) conn statement bind.data an SQLiteConnection object. a character vector of length one specifying the SQL statement that should be executed. Only a single SQL statment should be provided. A data frame of data to be bound.

14 sqlite-meta res n an SQLiteResult object. maximum number of records to retrieve per fetch. Use -1 to retrieve all pending records; use 0 for to fetch the default number of rows as defined in SQLite... Unused. Needed for compatibility with generic. con <- dbconnect(sqlite(), ":memory:") dbwritetable(con, "arrests", datasets::usarrests) # Run query to get results as dataframe dbgetquery(con, "SELECT * FROM arrests limit 3") # Send query to pull requests in batches res <- dbsendquery(con, "SELECT * FROM arrests") data <- fetch(res, n = 2) data dbhascompleted(res) dblistresults(con) dbclearresult(res) # Use dbsendpreparedquery/dbgetpreparedquery for "prepared" queries dbgetpreparedquery(con, "SELECT * FROM arrests WHERE Murder <?", data.frame(x = 3)) dbgetpreparedquery(con, "SELECT * FROM arrests WHERE Murder < (:x)", data.frame(x = 3)) dbdisconnect(con) sqlite-meta Database interface meta-data. See documentation of generics for more details. ## S4 method for signature SQLiteResult dbcolumninfo(res,...) ## S4 method for signature SQLiteResult dbgetrowsaffected(res,...) ## S4 method for signature SQLiteResult dbgetrowcount(res,...)

SQLiteConnection-class 15 ## S4 method for signature SQLiteResult dbhascompleted(res,...) ## S4 method for signature SQLiteResult dbgetstatement(res,...) res An object of class SQLiteResult... Ignored. Needed for compatibility with generic data(usarrests) con <- dbconnect(sqlite(), dbname=":memory:") dbwritetable(con, "t1", USArrests) dbwritetable(con, "t2", USArrests) dblisttables(con) rs <- dbsendquery(con, "select * from t1 where UrbanPop >= 80") dbgetstatement(rs) dbhascompleted(rs) info <- dbgetinfo(rs) names(info) info$fields fetch(rs, n=2) dbhascompleted(rs) info <- dbgetinfo(rs) info$fields dbclearresult(rs) # DBIConnection info names(dbgetinfo(con)) dbdisconnect(con) SQLiteConnection-class Class SQLiteConnection. SQLiteConnection objects are usually created by dbconnect

16 sqlitecopydatabase con <- dbconnect(sqlite(), dbname = tempfile()) dbdisconnect(con) sqlitecopydatabase Copy a SQLite database This function copies a database connection to a file or to another database connection. It can be used to save an in-memory database (created using dbname = ":memory:") to a file or to create an in-memory database as a copy of anothe database. sqlitecopydatabase(from, to) from to A SQLiteConnection object. The main database in from will be copied to to. Either a string specifying the file name where the copy will be written or a SQLiteConnection object pointing to an empty database. If to specifies an already existing file, it will be overwritten without a warning. When to is a database connection, it is assumed to point to an empty and unused database; the behavior is undefined otherwise. Details This function uses SQLite s experimental online backup API to make the copy. Value Returns NULL. Author(s) Seth Falcon References http://www.sqlite.org/backup.html

SQLiteDriver-class 17 ## Create an in memory database db <- dbconnect(sqlite(), dbname = ":memory:") df <- data.frame(letters=letters[1:4], numbers=1:4, stringsasfactors = FALSE) ok <- dbwritetable(db, "table1", df, row.names = FALSE) stopifnot(ok) ## Copy the contents of the in memory database to ## the specified file backupdbfile <- tempfile() sqlitecopydatabase(db, backupdbfile) diskdb <- dbconnect(sqlite(), dbname = backupdbfile) stopifnot(identical(df, dbreadtable(diskdb, "table1"))) ## Copy from one connection to another db2 <- dbconnect(sqlite(), dbname = ":memory:") sqlitecopydatabase(db, db2) stopifnot(identical(df, dbreadtable(db2, "table1"))) ## cleanup dbdisconnect(db) dbdisconnect(diskdb) dbdisconnect(db2) unlink(backupdbfile) SQLiteDriver-class Class SQLiteDriver with constructor SQLite. An SQLite driver implementing the R/S-Plus database (DBI) API. This class should always be initializes with the SQLite() function. It returns a singleton object that allows you to connect to the SQLite engine embedded in R. SQLite(max.con = 200L, fetch.default.rec = 500, force.reload = FALSE, shared.cache = FALSE) max.con,force.reload Ignored and deprecated. fetch.default.rec default number of records to fetch at one time from the database. The fetch method will use this number as a default, but individual calls can override it. shared.cache logical describing whether shared-cache mode should be enabled on the SQLite driver. The default is FALSE.

18 sqlitequickcolumn Details Value This implementation allows the R embedded SQLite engine to work with multiple database instances through multiple connections simultaneously. SQLite keeps each database instance in one single file. The name of the database is the file name, thus database names should be legal file names in the running platform. An object of class SQLiteDriver which extends dbdriver and dbobjectid. This object is needed to create connections to the embedded SQLite database. There can be many SQLite database instances running simultaneously. # initialize a new database to a tempfile and copy some data.frame # from the base package into it con <- dbconnect(sqlite(), ":memory:") data(usarrests) dbwritetable(con, "USArrests", USArrests) # query rs <- dbsendquery(con, "select * from USArrests") d1 <- fetch(rs, n = 10) # extract data in chunks of 10 rows dbhascompleted(rs) d2 <- fetch(rs, n = -1) # extract all remaining data dbhascompleted(rs) dbclearresult(rs) dblisttables(con) # clean up dbdisconnect(con) sqlitequickcolumn Return an entire column from a SQLite database Return an entire column from a table in a SQLite database as an R vector of the appropriate type. This function is experimental and subject to change. sqlitequickcolumn(con, table, column) con table column a SQLiteConnection object as produced by sqlitenewconnection. a string specifying the name of the table a string specifying the name of the column in the specified table to retrieve.

SQLiteResult-class 19 Details Value This function relies upon the SQLite internal ROWID column to determine the number of rows in the table. This may not work depending on the table schema definition and pattern of update. an R vector of the appropriate type (based on the type of the column in the database). Author(s) Seth Falcon SQLiteResult-class Class SQLiteResult SQLite s query results class. select or not). This classes encapsulates the result of an SQL statement (either transactions SQLite transaction management. By default, SQLite is in auto-commit mode. dbbegin starts a SQLite transaction and turns autocommit off. dbcommit and dbrollback commit and rollback the transaction, respectively and turn auto-commit on. ## S4 method for signature SQLiteConnection dbbegin(conn, name = NULL) ## S4 method for signature SQLiteConnection dbcommit(conn, name = NULL) ## S4 method for signature SQLiteConnection dbrollback(conn, name = NULL) conn name a SQLiteConnection object, produced by dbconnect Supply a name to use a named savepoint. This allows you to nest multiple transaction

20 transactions Value A boolean, indicating success or failure. con <- dbconnect(sqlite(), ":memory:") dbwritetable(con, "arrests", datasets::usarrests) dbgetquery(con, "select count(*) from arrests") dbbegin(con) rs <- dbsendquery(con, "DELETE from arrests WHERE Murder > 1") dbgetrowsaffected(rs) dbclearresult(rs) dbgetquery(con, "select count(*) from arrests") dbrollback(con) dbgetquery(con, "select count(*) from arrests")[1, ] dbbegin(con) rs <- dbsendquery(con, "DELETE FROM arrests WHERE Murder > 5") dbclearresult(rs) dbcommit(con) dbgetquery(con, "SELECT count(*) FROM arrests")[1, ] # Named savepoints can be nested -------------------------------------------- dbbegin(con, "a") dbbegin(con, "b") dbrollback(con, "b") dbcommit(con, "a") dbdisconnect(con)

Index Topic interface sqlitequickcolumn, 18 datasetsdb, 2 dbbegin,sqliteconnection-method (transactions), 19 dbclearresult,sqliteconnection-method (query), 13 dbclearresult,sqliteresult-method (query), 13 dbcolumninfo,sqliteresult-method (sqlite-meta), 14 dbcommit,sqliteconnection-method (transactions), 19 dbconnect, 8, 11, 15, 19 dbconnect,sqliteconnection-method (dbconnect,sqlitedriver-method), 3 dbconnect,sqlitedriver-method, 3 dbdatatype, 11 dbdatatype,sqliteconnection-method, 4 dbdatatype,sqlitedriver-method (dbdatatype,sqliteconnection-method), 4 dbdisconnect,sqliteconnection-method (dbconnect,sqlitedriver-method), 3 dbexiststable,sqliteconnection,character-method, 5 dbfetch,sqliteresult-method (query), 13 dbgetinfo, 5 dbgetinfo,sqliteconnection-method (dbgetinfo), 5 dbgetinfo,sqlitedriver-method (dbgetinfo), 5 dbgetinfo,sqliteresult-method (dbgetinfo), 5 dbgetpreparedquery (dbsendpreparedquery), 9 21 dbgetpreparedquery,sqliteconnection,character,data.frame-m (query), 13 dbgetquery,sqliteconnection,character-method (query), 13 dbgetrowcount,sqliteresult-method (sqlite-meta), 14 dbgetrowsaffected,sqliteresult-method (sqlite-meta), 14 dbgetstatement,sqliteresult-method (sqlite-meta), 14 dbhascompleted,sqliteresult-method (sqlite-meta), 14 dbisvalid, 6 dbisvalid,sqliteconnection-method (dbisvalid), 6 dbisvalid,sqlitedriver-method (dbisvalid), 6 dbisvalid,sqliteresult-method (dbisvalid), 6 dblistfields,sqliteconnection,character-method, 7 dblistresults,sqliteconnection-method (query), 13 dblisttables,sqliteconnection-method, 7 dbreadtable,sqliteconnection,character-method, 8 dbremovetable,sqliteconnection,character-method, 9 dbrollback,sqliteconnection-method (transactions), 19 dbsendpreparedquery, 9 dbsendpreparedquery,sqliteconnection,character,data.frame- (query), 13 dbsendquery,sqliteconnection,character-method (query), 13 dbunloaddriver,sqlitedriver-method, 10 dbwritetable,sqliteconnection,character,character-method (dbwritetable,sqliteconnection,character,data.frame

22 INDEX 10 dbwritetable,sqliteconnection,character,data.frame-method, 10 fetch,sqliteresult-method (query), 13 initextension, 12 isidcurrent (dbisvalid), 6 make.db.names, 11 query, 13 read.table, 11 SQLite, 3, 10, 14 SQLite (SQLiteDriver-class), 17 sqlite-meta, 14 SQLITE_RO (dbconnect,sqlitedriver-method), 3 SQLITE_RW (dbconnect,sqlitedriver-method), 3 SQLITE_RWC (dbconnect,sqlitedriver-method), 3 SQLiteConnection, 3, 5, 7 9, 11, 13, 19 SQLiteConnection-class, 15 sqlitecopydatabase, 16 SQLiteDriver, 5 SQLiteDriver-class, 17 sqlitequickcolumn, 18 SQLiteResult, 5, 14, 15 SQLiteResult-class, 19 transactions, 19