SQLite: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
{{Draft}}
{{Draft}}


[https://www.sqlite.org SQLite] is a "pocket database", in that it is a full-featured relational database which however dispenses with the client/server architecture of most such databases and instead exists entirely in a single diskfile. Software in a wide variety of common languages can read and write to this database file using standard [https://en.wikipedia.org/wiki/SQL SQL] queries using the language's standard API for database interactions, assuming one exists and the database can be transferred to another computer simply by copying the file there.  
[https://www.sqlite.org SQLite] is a "pocket database", in that it is a full-featured relational database which however dispenses with the client/server architecture of most such databases and instead exists entirely in a single diskfile. Software in a wide variety of common languages can read from and write to this database file using standard [https://en.wikipedia.org/wiki/SQL SQL] queries using the language's standard API for database interactions, assuming one exists and the database can be transferred to another computer simply by copying the file there.  


==Using SQLite directly==
==Using SQLite directly==
Line 23: Line 23:
   |contents=
   |contents=
library(DBI)
library(DBI)
# Connect to the database...
dbase <- dbConnect(RSQLite::SQLite(),"foo.sqlite")
dbase <- dbConnect(RSQLite::SQLite(),"foo.sqlite")


# A parameterized query
rs <- dbSendQuery(dbase,"SELECT * FROM tname",params = list(tname = "employees"))
while (!dbHasCompleted(rs)) {
  # Grab a maximum of ten rows at a time...
  df <- dbFetch(rs,n = 10)
  # Print the number of rows we actually got from dbFetch
  print(nrow(df))
}
dbClearResult(rs)
#Close the database connection
dbDisconnect(dbase)
dbDisconnect(dbase)
}}
}}
Bureaucrats, cc_docs_admin, cc_staff
2,318

edits

Navigation menu