View source: R/get_anything_sql.R
get_anything_sql | R Documentation |
Extract any information from any database. This function is for people who know sql and understand the database well enough
to write their own sql statements. For all others, please see the get_landings
and other similar functions
get_anything_sql(channel, sqlStatement)
channel |
an Object inherited from DBIConnection-class. This object is used to connect
to communicate with the database engine. (see |
sqlStatement |
an sql statement |
A list is returned:
- data
containing the result of the executed sqlStatement
and
- sql
containing the sqlStatement
itself
- colNames
a vector of the table's column names
There is no default sql statement.
You will need to obtain read only privilages to access any of the databases Some of the databases contains many million records. If you try to pull the entire database it is likely you will run out of memory.
Use the data dictionary (http://nova.nefsc.noaa.gov/datadict/) for field name explanations
connect_to_database
Other get functions:
get_age_length()
,
get_areas()
,
get_gears()
,
get_landings_length()
,
get_landings_palmer()
,
get_landings()
,
get_locations()
,
get_ports()
,
get_species_itis()
,
get_species()
,
get_vessels()
## Not run:
# extracts landings for cod (081) in area 500 for ton class >=10 by <20 using gear types (1,2,10)
channel <- connect_to_database(server="name_of_server",uid="individuals_username")
sqlStatement <- "select year, month, nespp3, negear2, toncl2, trplndlb, area from stockeff.mv_cf_landings
where (area in (500,600)) and (negear2 in (1,2,10)) and (nespp3 in 81) and (year in ('1999')) and (toncl2 like '1%');"
get_anything_sql(channel,sqlStatement)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.