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

morph_lib.database
# 📦 Package: morph_lib.database
# 🛠️ Function: execute_sql

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

Parameters

sql
string
required

SQL to execute

connection
string

Destination of the connection other than the built-in registered on the screen (optional)

  • If not specified, it will be set to 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