mdb2pg: 'mdb2pg' Write entire SMRU Access database to PostgreSQL

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/getSRDLdb.R

Description

mdb2pg Write entire SMRU Access database to PostgreSQL

Usage

1
mdb2pg(mdb = "ct34", pg = "SRDL", append = F)

Arguments

mdb

Either a character string giving the name of MS Access database as defined in ODBC data sources or the name of an R list which is the result of reading an entire SMRU Access deployments database (using the get.all.SRDLdb function)

pg

Name of PostgreSQL database into which tables should be written

append

Logical, indicating whether to create table (default) or append to existing table

Details

The source MS Access database must first be set up as a DSN data source. Note! On Windows, only 32-bit data sources can be used, and R (or RStudio) has to be run in 32-bit mode for these functions to work. In addition, a PostgreSQL/PostGIS database must exist that can hold the tables.

Value

Returns nothing, but re-creates a PostgreSQL representation of the MS Access database, potentially merging several deployments into single set of tables.

Author(s)

Martin Biuw

See Also

tables.SRDLdb for database table names, fields.SRDLdb for table field names, ref.SRDLdb for ref ID codes, dep.SRDLdb for retrieving deployments metadata get.SRDLdb for retrieving single tables based on given selection criteria get.all.SRDLdb for retrieving entire SMRU Access database

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
mdb2pg('ct34')
for(i in all.mdb) {
  cat('Converting database', i, '(', match(i, all.mdb), 'of', length(all.mdb), ')\n')
  flush.console()
  if(match(i, all.db)==1) {
    mdb2pg(i)
  } else{
    mdb2pg(i)
  }
}

embiuw/rSRDL documentation built on Jan. 27, 2021, 8:11 p.m.