1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Passing Pandas dataframe through sql query to connect to external database

Discussão em 'Python' iniciado por Stack, Setembro 11, 2024.

  1. Stack

    Stack Membro Participativo

    I have a pandas dataframe named outliers, which contains a list of people with IDs. I need to connect to SnowFlake database to pull some fields on these members. Is it possible to pass pandas dataframe name through the sql query to achieve this?

    This is my logic:

    query = f"""
    select a.*, b.name
    from {outliers} as a
    inner join snowflake_table as b on a.mbr_id = b.mbr_id
    """
    query_result = pandas.read_sql(sql=query, con=con)


    I am getting an error message saying "Syntax error line 5 at position 37 unexpected ..." (one of variable names). Any recommendations?

    Continue reading...

Compartilhe esta Página