限制为10万行

2024-04-19 12:47:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在查询一个历史数据库,结果表应该有大约144k行,但是我得到的结果限制在100k行。使用ODBC连接到同一个数据库,但是使用VBA.NET应用程序,我已经发现了这个问题。你知道吗

我在dbsql客户机中测试了相同的查询,它返回了正确的行数。唯一看起来可疑的是,这个客户机对其接口上显示的行数有限制,默认值是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()

在我查询数据库的这段时间里,我预计会有144k行,但我只得到100k行


Tags: andimport数据库formatdf客户机timetag