Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to fetch limited rows in pandas dataframe using sqlalchemy

import sqlalchemy as db
import pandas as pd

engine = db.create_engine('sqlite:///traffic.sqlite') # just for example
con=engine.connect()
dbqu=con.execute("SELECT * FROM vehicles")
## use fetchmany(size=x) instead of fetchall() to fetch x number of rows
df=pd.DataFrame(dbqu.fetchmany(size=20))  
con.close()
 
PREVIOUS NEXT
Tagged: #fetch #limited #rows #pandas #dataframe #sqlalchemy
ADD COMMENT
Topic
Name
7+5 =