get_anything_sql: Extract anything from ADIOS! or CFDBS

View source: R/get_anything_sql.R

get_anything_sqlR Documentation

Extract anything from ADIOS! or CFDBS

Description

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

Usage

get_anything_sql(channel, sqlStatement)

Arguments

channel

an Object inherited from DBIConnection-class. This object is used to connect to communicate with the database engine. (see connect_to_database)

sqlStatement

an sql statement

Value

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.

Warning

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.

Reference

Use the data dictionary (http://nova.nefsc.noaa.gov/datadict/) for field name explanations

See Also

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()

Examples

## 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)


andybeet/cfdbs documentation built on Sept. 19, 2023, 9:34 p.m.