I am querying a historical database and the result table should have around 144k rows but I am getting the result limited to 100k lines. I have already seem this problem using ODBC connection to the same DB but using a VBA .NET application.
I tested the same query in the DB SQL client and it return the correct number of row. The only thing that look suspect is that this client has a limit to number of rows shown on its interface and the default value is 100k.
import pypyodbc as pyodbc
import pandas as pd
import gc
import time
def GetTrend(tags,server,t_ini,t_end,period):
IP21_connection = 'DRIVER={{AspenTech SQLplus}};HOST={};PORT=10014'
IP21_Query = """select ts,avg from aggregates where name = '{}'
and ts between '{}' and '{}'
and period = 10*{}"""
conn = pyodbc.connect(IP21_connection.format(server))
cur = conn.cursor()
df2=pd.DataFrame()
i=0
for tag in tags:
cur.execute(IP21_Query.format(tag,t_ini,t_end,period))
df = pd.DataFrame(cur.fetchall(),columns=['ts',tag])
df['ts'] = pd.to_datetime(df['ts'])
df1=df.set_index('ts')
df2=pd.concat([df2,df1],axis=1)
i+=1
print('{} - {} of {} tags'
' collected'.format(time.asctime(time.localtime()), i,
len(tags)), flush=True)
gc.collect()
For the period I am querying the DB I would expect 144k rows but I am getting just 100k.