OceanDB.OceanDB#

class OceanDB.OceanDB.OceanDB(config=None)#

Bases: object

Base class for all classes that interface with the Postgres database

This class expects a .env file at the project root with database credentials. See instructions in the README

Parameters:

config (Config | None)

basin_mask(latitude, longitude)#

Get basin_id from lat & lng

cursor(*, autocommit=False, commit=False, use_geometry=False, row_factory=<function tuple_row>, connection_string=None)#

Managed PostgreSQL cursor for all OceanDB database access.

Parameters:
  • autocommit (bool)

  • commit (bool)

  • use_geometry (bool)

  • connection_string (str | None)

drop_database()#
get_engine(echo=False)#

Return a SQLAlchemy engine connected to the OceanDB Postgres database.

Parameters:

echo (bool)

load_module_file(module, filename, encoding='utf-8', mode='rb')#

Open a resource file bundled within a Python package.

Handles both text (‘r’) and binary (‘rb’) modes safely. Automatically omits encoding when opening in binary mode.

Parameters:
  • module (str)

  • filename (str)

  • mode (Literal['r', 'rb'])

Return type:

IO

load_sql_file(filename)#

Load the contents of a SQL file

Parameters:

filename (str)

Return type:

LiteralString

truncate_table(name)#
vacuum_analyze()#
property basin_connection_map: dict#
property basin_mask_data#

Load the basin mask NetCDF file packaged with the module. Returns the ‘basinmask’ variable as a NumPy array.