79603564

Date: 2025-05-02 14:30:32
Score: 0.5
Natty:
Report link

this work for me with pandas
settings.py

APP_BBDD = {
    "LOCAL": {
        "DNS": "localhost:1521/XE", <- LOOK THIS!!
        "USER": "USERNAME",
        "PASS": "holaqase",
    }
}   

And

import pandas as pd
import oracledb
import settings


def check_bbdd(environment = "LOCAL"):
    """
    check bbdd
    """

    df = _get_df("SELECT * FROM TABLE_NAME",environmet)
    print(df.head())
    return df

def _get_df(query, environmet = "LOCAL"):
    with oracledb.connect(
        user=settings.APP_BBDD[environment]["USER"],
        password=settings.APP_BBDD[environment]["PASS"],
        dsn=settings.APP_BBDD[environment]["DNS"],
    ) as conn:
        return pd.read_sql(query, conn)

And one test:

enter image description here

😘

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Barrrettt