Learn R Programming

ProjectTemplate (version 0.3-5)

sql.reader: Read a database described in a...

Description

Read a database described in a .sql file.

Usage

sql.reader(data.file, filename, variable.name)

Arguments

data.file
The name of the data file to be read.
filename
The path to the data set to be loaded.
variable.name
The name to be assigned to in the global environment.

Value

  • No value is returned; this function is called for its side effects.

Details

This function will load data from a SQL database based on configuration information found in the specified .sql file. The .sql file must specify a database to be accessed. All tables from the database, one specific tables or one specific query against any set of tables may be executed to generate a data set.

Examples of the DCF format and settings used in a .sql file are shown below:

Example 1 type: mysql user: sample_user password: sample_password host: localhost dbname: sample_database table: sample_table

Example 2 type: sqlite dbname: /path/to/sample_database table: sample_table

Example 3 type: sqlite dbname: /path/to/sample_database query: SELECT * FROM users WHERE user_active == 1

Example 4 type: sqlite dbname: /path/to/sample_database table: *

Examples

Run this code
library('ProjectTemplate')

#sql.reader('example.sql', 'data/example.sql', 'example')}

Run the code above in your browser using DataLab