Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
fastapi snowflake connection only pulling 1 record

I am trying to read data from snowflake database using FASTAPI. I was able to create the connection which is able to pull data from snowflake.

The issue which I am facing right now is that I am only getting 1 record (instead of 10 records). I suspect I am not using correct keyword while returning the data. appreciate any help.

Here is my code :-

from fastapi import FastAPI
import snowflake.connector as sf
import configparser


username='username_value'
password='password_value'
account= 'account_value'
warehouse= 'test_wh'
database= 'test_db'


ctx=sf.connect(user=username,password=password,account=account,warehouse=warehouse,database=database)

app = FastAPI()
@app.get('/test API')
async def fetchdata():
  cursor = ctx.cursor()
  cursor.execute("USE WAREHOUSE test_WH ")
  cursor.execute("USE DATABASE test_db") 
  cursor.execute("USE SCHEMA test_schema")
  sql = cursor.execute ("SELECT DISTINCT ID,NAME,AGE,CITY FROM TEST_TABLE WHERE AGE > 60")

for data in sql:
  return data
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You use return in your inner for-loop. This will return the first row encountered.

If you want to return all rows as a list, you can probably do (I'm not familiar with the snowflake connector):

return list(data)

instead of the for-loop, or sql.fetchall().

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda