0
import os

import pandas as pd
from jaydebeapi import connect


def sql_query(query: str) -> pd.DataFrame:
    jclassname = "classname"

    url = "urlToCluster"

    driver_args = {"keys":"values"}

    path = "pathToJars"
    jars = [f"{path}{item}" for item in os.listdir(path)]
    with connect(jclassname=jclassname, url=url, driver_args=driver_args, jars=jars) as engine:
        df = pd.read_sql_query(query, engine)

    return df

When ever I connect to my sql jars, there is a ton of debug log outputs. I can't seem to figure out how to suppress these logs. I've tried using logging to turn off all logs but that doesn't seem to work. I'm at a loss as to what to do. I have a feeling it has something to do with jaydebeapi and java. The documentation of jaydebeapi is vague on it's features.

kcrich
  • 1

2 Answers2

0

You said you've tried logging to turn off all logs, but it didn't work. Try this line and tell me if it works:

import logging
logging.getLogger("jaydebeapi").setLevel(logging.WARNING)

This should only show warnings from the API.

NumberC
  • 596
  • 7
  • 17
  • Thank you for your response. It didn't work. It feels like the jar files are forcing their logs through. I'm curious if there's a way to edit the jars or the java environment itself to suppress this. – kcrich Jul 07 '20 at 16:55
0

Jaydebeapi has almost no logging. The logs come from the Java JDBC driver. You have to find out how to disable them on the Java side. Most probably you have to set some system properties. Unless Jaydebeapi adds direct support for system parameters or system properties you have to set them by starting java manually via JPype in advance and pass them on the JPype.startJVM() invocation before using Jaydebeapi.

bastian
  • 1,122
  • 11
  • 23