Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!