Executes the SQL and returns the result as a DataFrame. It can access all databases connected via built-in PostgreSQL and SQL Connection.

from morph_lib.database import execute_sql

execute_sql(
	sql: str,
	connection: Optional[str]
) -> pd.DataFrame

Parameters

sql
string
required

The SQL to be executed.

connection
string

Destination of the connection other than the registered builtin connection (optional)

*If not specified, it will be set to the built-in PostgreSQL.

Example

from morph_lib.database import execute_sql

@morph.func
def func_name(context):
	data: pd.DataFrame = execute_sql("SELECT * FROM user;")
	return data