vyperdatum.db

Attributes

logger

Classes

DB

Module Contents

vyperdatum.db.logger
class vyperdatum.db.DB(db_dir: str | None = enuPDB.DIR.value)
db_dir
db_name
property db_file_path: str
update_db_path() bool

Prepend self.db_dir to pyproj.datadir which guides the pyproj to first look for the database at self.db_dir address.

Raises:
  • ValueError: – If .db_dir is not set.

  • FileNotFoundError: – If the database file is not found.

Returns:

True if the data_dir is set successfully, otherwise False.

Return type:

bool

query(sql: str, dataframe: bool = False) list | None | pandas.DataFrame | None

Execute a sql query and return the response. This method is intended to run a read (scan) query. Avoid using this method for DML/DDL type operations.

Parameters:
  • sql (str) – SQL query (intended to be a scan query) to be executed.

  • dataframe (bool, default=False) – If True, converts the result into a pandas dataframe.

Return type:

list or pd.DataFrame

crs_by_keyword(keywords: list[str], dataframe: bool = False) list | None | pandas.DataFrame | None

Return a list (or dataframe) of CRS that their name or description contain the passed keywords. The search is not case-sensitive.

Parameters:
  • sql (str) – SQL query (intended to be a scan query) to be executed.

  • keywords (list[str]) – A list of string keywords used to query the database.

  • dataframe (bool, default=False) – If True, converts the result into a pandas dataframe.

Raises:
  • TypeError: – If keywords is not a list of strings.

  • ValueError: – If no keywords is passed.

Return type:

list or pd.DataFrame