% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/GeoTox.R
\name{GeoTox}
\alias{GeoTox}
\alias{get_con}
\title{GeoTox S3 object}
\usage{
GeoTox(dbname = tempfile(fileext = ".duckdb"), reset_seed = FALSE, ...)

get_con(GT)
}
\arguments{
\item{dbname}{Database file name. Default is a temporary file.}

\item{reset_seed}{Logical indicating whether to reset the user's global
\code{.Random.seed} after certain database operations (default \code{FALSE}).}

\item{...}{Additional arguments passed to \code{\link[duckdb:duckdb]{duckdb::duckdb()}}.}

\item{GT}{GeoTox object.}
}
\value{
For \code{GeoTox()}, a GeoTox S3 object. For \code{get_con()}, a database
connection.
}
\description{
Create a GeoTox object and connect to the underlying database.
}
\details{
The \code{dbname} will point to a DuckDB database file. If the file does not
already exist, a new database will be created. Additional arguments passed
via \code{...} will be forwarded to \code{\link[duckdb:duckdb]{duckdb::duckdb()}}.

The \code{reset_seed} parameter is necessary for replicating results from the
previous GeoTox implementation. Some database functions create temporary
tables where a random string is appended to the table name. This advances the
\code{.Random.seed} state and causes functions that use randomness to produce
different results between the previous and current implementations. Setting
\code{reset_seed = TRUE} will reset the user's \code{.Random.seed} to the value it had
before certain database operations.

Various parameters will be stored in the 'par' table. These parameters will
also be loaded into the GeoTox object as a list in \code{GT$par}. The value for
\code{reset_seed} can only be set on initial GeoTox object creation and will be
loaded from the 'par' table for existing databases.
}
\examples{
# Create a GeoTox object
GT <- GeoTox()

# Open a connection to GeoTox database
con <- get_con(GT)

# List database tables
DBI::dbListTables(con)

# Look at the GT parameters
dplyr::tbl(con, "par") |> dplyr::collect()
str(GT$par)

# Clean up example
DBI::dbDisconnect(con)
file.remove(GT$db_info$dbdir)
}
