The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
There are different ways to open a connection and to get data.
Prepare database with a table
<- rocker::newDB() # New database handling object
db #> dctr | New object
$setupSQLite(dbname = tempfile()) # Setup SQLite database
db#> Dctr | Driver load RSQLite
$connect() # Open connection
db#> DCtr | Database connected
$writeTable("mtcars", mtcars) # Create table for testing
db#> DCtr | Write table mtcars columns mpg, cyl, disp, hp, drat, wt, qsec, vs, am, gear, carb rows 32
$disconnect() # Close connection
db#> Dctr | Database disconnected
Example 1
Get query with automatic connection / disconnection
<- db$getQuery("SELECT * FROM mtcars;") # Get query
output #> DCtr | Database connected
#> DCtR | Send query 21 characters
#> DCtR | Fetch rows all -> Received 32 rows, 11 columns, 4824 bytes
#> DCtR | Rows fetched 32
#> DCtR | Has completed yes
#> DCtr | Clear result
#> Dctr | Database disconnected
Example 2
Get query with manual connection / disconnection
$connect() # Open connection
db#> DCtr | Database connected
<- db$getQuery("SELECT * FROM mtcars;") # Get query 1
output1 #> DCtR | Send query 21 characters
#> DCtR | Fetch rows all -> Received 32 rows, 11 columns, 4824 bytes
#> DCtR | Rows fetched 32
#> DCtR | Has completed yes
#> DCtr | Clear result
<- db$getQuery("SELECT * FROM mtcars;", 15) # Get query 2
output2 #> DCtR | Send query 21 characters
#> DCtR | Fetch rows 15 -> Received 15 rows, 11 columns, 3416 bytes
#> DCtR | Rows fetched 15
#> DCtR | Has completed no
#> DCtR | Fetch rows 15 -> Received 15 rows, 11 columns, 3416 bytes
#> DCtR | Rows fetched 30
#> DCtR | Has completed no
#> DCtR | Fetch rows 15 -> Received 2 rows, 11 columns, 2184 bytes
#> DCtR | Rows fetched 32
#> DCtR | Has completed yes
#> DCtr | Clear result
$disconnect() # Close connection
db#> Dctr | Database disconnected
Example 3
Function getQuery() is a combination of functions sendQuery(), fetch() and clearResult().
$connect() # Open connection
db#> DCtr | Database connected
$sendQuery("SELECT * FROM mtcars;") # Send query
db#> DCtR | Send query 21 characters
<- db$fetch() # Fetch result
output #> DCtR | Fetch rows all -> Received 32 rows, 11 columns, 4824 bytes
$clearResult() # Clean up result
db#> DCtr | Clear result
$disconnect() # Close connection
db#> Dctr | Database disconnected
Clean up
$unloadDriver() # Reset database handling object
db#> dctr | Driver unload RSQLite
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.