gpf_entrepot_toolbelt.sql.sql_tools module

Helpers to manipulate SQL embedded files.

gpf_entrepot_toolbelt.sql.sql_tools.copy_file_to(sql_name: str, dest_folder_path: Path) Path

Copy (content and mode) embedded SQL file to another place.

Paramètres:
  • sql_name (str) – name of sql file, with or without .sql extension.

  • dest_folder_path (Path) – path to the folder where copy. Must be a folder. Supports variables. If it does not exist, it’s created.

Lève:

FileNotFoundError – if input file name is not found within embedded SQL files

Renvoie:

path to the copied file

Type renvoyé:

Path

Exemple

>>> new_path = copy_file_to("compute_gpf_extent", "~/destination_folder")
>>> print(type(new_path), new_path)
<class 'pathlib.PosixPath'> /home/jmo/destination_folder/compute_gpf_extent.sql
gpf_entrepot_toolbelt.sql.sql_tools.execute_sql_file(sql_filename: str) None

Execute commands from SQL file.

Paramètres:

sql_filename (str) – name of sql file, with or without .sql extension.

gpf_entrepot_toolbelt.sql.sql_tools.get_sql_path(sql_name: str) Path

Return absolute path to SQL file required by its name.

Paramètres:

sql_name (str) – name of sql file, with or without .sql extension.

Renvoie:

path to the SQL file

Type renvoyé:

Path

Exemple

>>> sql_file = get_sql_path("compute_gpf_extent")
>>> print(sql_file.absolute())
/usr/bin/python/jmo/Git/IGN/gpf-entrepot-toolbelt-py/gpf_entrepot_toolbelt/sql/compute_gpf_extent.sql
gpf_entrepot_toolbelt.sql.sql_tools.list_embedded_sql() list[Path]

List embedded SQL files.

Renvoie:

list of SQL files

Type renvoyé:

list[Path]