简体   繁体   English

使用Pyodbc查询Vertica时的python缓冲区大小

[英]python buffer size when querying Vertica using Pyodbc

i am using pyodbc to connect to Vertica DB and then i am using cursor to execute a query but the results of the query include a text field that is huge, the execute runs but it never returns anything, not even an exception. 我正在使用pyodbc连接到Vertica DB,然后我使用游标执行查询,但是查询的结果包括一个巨大的文本字段,执行运行,但它从不返回任何内容,甚至没有异常。 I can see this when i debug and break point at row=cursor.fetchall() It just comes as empty just like this "[]" 当我在row = cursor.fetchall()调试并断点时,我可以看到它,就像这个“ []”一样,它是空的

If i try with another dataset with less characters in this huge text field then the execute runs and i get data. 如果我尝试在此巨大的文本字段中使用字符较少的另一个数据集,则执行会运行,并且我会获取数据。 I am suspecting it has to do with buffer size when retrieving the data but i don't know. 我怀疑它与检索数据时的缓冲区大小有关,但我不知道。 Any suggestions on how to do this? 有关如何执行此操作的任何建议? Maybe increase buffer size somehow? 也许以某种方式增加缓冲区大小?

Thanks 谢谢

import requests, pypyodbc, json, pyvertica, pyodbc
from pyvertica import connection
    conn=pyodbc.connect("DSN=HPVertica;UID=muffin;PWD=muffin")
    cursor=conn.cursor()
    query="SELECT field1_int, field2_bigText  FROM someTable WHERE field1_int=103;"

    try:
        cursor.execute(query)
    except Exception as e:
        print('err: {}'.format(e.args[0]))
        print(': {}'.format(e.args[1]))

    row=cursor.fetchall()

I believe this is a known issue in pyodbc, at least I am sure I've seen this complained about before and also some random patches. 我相信这是pyodbc中的一个已知问题,至少我敢肯定,我以前曾经看过这个问题,也有一些随机补丁。 I just looked at the pyodbc code and it looks like they very recently fixed the issue in this commit a couple weeks ago. 我只是看了pyodbc代码,看起来好像他们最近在几周前的提交中解决了这个问题。

It doesn't appear to be in the latest (as of this post) tag of 3.0.10. 它似乎没有出现在最新的(截至本文中)标记3.0.10中。 You'd either have to try the bleeding edge or wait just a little longer for it to be included in a future tag. 您要么必须尝试最新的技术,要么再等一会儿再将其包含在将来的代码中。 (Or patch it yourself based on that commit, I guess). (我猜是根据提交来自己打补丁)。

我使用pypyodbc而不是pyodbc解决了这个问题,不再出现缓冲区错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM