Browse Source

pgcon vs con

master
boB Rudis 3 years ago
parent
commit
b2a0a07250
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 2
      DESCRIPTION
  2. 12
      R/create-cidr-tbl.R
  3. 12
      R/create-ip-tbl.R
  4. 4
      R/find-ips-in-cidrs.R
  5. 2
      R/macos-setup.R
  6. 2
      man/macos_postgresql_setup_with_ip4r.Rd

2
DESCRIPTION

@ -27,4 +27,4 @@ Imports:
glue,
readr
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1

12
R/create-cidr-tbl.R

@ -45,7 +45,7 @@
create_cidr_lookup_table <- function(pgcon, tbl_name, drop=FALSE, xdf,
entity_col="entity", cidr_col="cidr") {
stopifnot(inherits(con, "PostgreSQL"))
stopifnot(inherits(pgcon, "PostgreSQL"))
tbl_name <- tbl_name[1]
idx_name <- ac(gg("{tbl_name}_idx"))
@ -69,14 +69,14 @@ create_cidr_lookup_table <- function(pgcon, tbl_name, drop=FALSE, xdf,
}
if (drop) {
dbExecute(con, ac(gg("DROP TABLE IF EXISTS {tbl_name}")))
dbExecute(con, ac(gg("DROP INDEX IF EXISTS {idx_name}")))
dbExecute(pgcon, ac(gg("DROP TABLE IF EXISTS {tbl_name}")))
dbExecute(pgcon, ac(gg("DROP INDEX IF EXISTS {idx_name}")))
}
dbExecute(con, ac(gg("CREATE TABLE {tbl_name}({entity_col} text not null, {cidr_col} ip4r primary key)")))
dbExecute(pgcon, ac(gg("CREATE TABLE {tbl_name}({entity_col} text not null, {cidr_col} ip4r primary key)")))
dbExecute(con, ac(gg("COPY {tbl_name} FROM '{tf}' WITH (format csv, header)")))
dbExecute(con, ac(gg("CREATE INDEX {idx_name} ON {tbl_name} USING gist({cidr_col})")))
dbExecute(pgcon, ac(gg("COPY {tbl_name} FROM '{tf}' WITH (format csv, header)")))
dbExecute(pgcon, ac(gg("CREATE INDEX {idx_name} ON {tbl_name} USING gist({cidr_col})")))
invisible(NULL)

12
R/create-ip-tbl.R

@ -40,7 +40,7 @@
#' }
create_ip_source_table <- function(pgcon, tbl_name, drop=FALSE, xdf, ip_col = "ip") {
stopifnot(inherits(con, "PostgreSQL"))
stopifnot(inherits(pgcon, "PostgreSQL"))
tbl_name <- tbl_name[1]
idx_name <- ac(gg("{tbl_name}_idx"))
@ -64,14 +64,14 @@ create_ip_source_table <- function(pgcon, tbl_name, drop=FALSE, xdf, ip_col = "i
if (drop) {
dbExecute(con, ac(gg("DROP TABLE IF EXISTS {tbl_name}")))
dbExecute(con, ac(gg("DROP INDEX IF EXISTS {idx_name}")))
dbExecute(pgcon, ac(gg("DROP TABLE IF EXISTS {tbl_name}")))
dbExecute(pgcon, ac(gg("DROP INDEX IF EXISTS {idx_name}")))
}
dbExecute(con, ac(gg("CREATE TABLE {tbl_name}({ip_col} ip4 not null)")))
dbExecute(pgcon, ac(gg("CREATE TABLE {tbl_name}({ip_col} ip4 not null)")))
dbExecute(con, ac(gg("COPY {tbl_name} FROM '{tf}' WITH (format csv, header)")))
dbExecute(con, ac(gg("CREATE INDEX {idx_name} ON {tbl_name}({ip_col})")))
dbExecute(pgcon, ac(gg("COPY {tbl_name} FROM '{tf}' WITH (format csv, header)")))
dbExecute(pgcon, ac(gg("CREATE INDEX {idx_name} ON {tbl_name}({ip_col})")))
invisible(NULL)

4
R/find-ips-in-cidrs.R

@ -39,7 +39,7 @@
find_ips_in_cidrs <- function(pgcon, ip_tbl, cidr_tbl,
ip_col = "ip", cidr_col = "cidr") {
stopifnot(inherits(con, "PostgreSQL"))
stopifnot(inherits(pgcon, "PostgreSQL"))
ip_tbl <- ip_tbl[1]
cidr_tbl <- cidr_tbl[1]
@ -47,7 +47,7 @@ find_ips_in_cidrs <- function(pgcon, ip_tbl, cidr_tbl,
cidr_col <- cidr_col[1]
DBI::dbGetQuery(
con,
pgcon,
ac(gg("
SELECT
*

2
R/macos-setup.R

@ -23,7 +23,7 @@
#'
#' ```shell
#' $ initdb DATA_PATH -E utf8
#' $ pg_ctl -D /Volumes/otg/postgres -l logfile start
#' $ pg_ctl -D /path/to/postgres -l logfile start
#' ```
#'
#' Make sure it's running

2
man/macos_postgresql_setup_with_ip4r.Rd

@ -20,7 +20,7 @@ $ brew install petere/postgresql/postgresql-common
}\if{html}{\out{</div>}}
Initialize the DB and start PG\if{html}{\out{<div class="shell">}}\preformatted{$ initdb DATA_PATH -E utf8
$ pg_ctl -D /Volumes/otg/postgres -l logfile start
$ pg_ctl -D /path/to/postgres -l logfile start
}\if{html}{\out{</div>}}
Make sure it's running\if{html}{\out{<div class="shell">}}\preformatted{$ ps -ef | grep postgr

Loading…
Cancel
Save