在2个不同的vertica连接上进行多线程处理

时间:2015-07-14 21:38:20

标签: python multithreading pyodbc vertica

我正在编写一个从Vertica数据库运行多个查询的python脚本。我读到vertica不支持在一个数据库连接上进行这种并发处理,所以我创建了两个。我想知道是否有人可以帮我弄清楚为什么以下不起作用?我已经使用单个连接对此进行了测试,但似乎第二个问题导致了问题。

提前致谢,

days = range(1,31)
full_days = []
for i in days:
    a = "2015-06-" + str(i)
    full_days.append(a)

queries = []
for i in full_days:
    queries.append("select count(*) from table where date(created = " + i)


start_time = time.time()
def run_queries_diff(queries):
    print 'starting'
    x = ['DRIVER=Vertica;SERVER=vertica1;DATABASE=abc;PORT=5433;UID=;PWD=', 'DRIVER=Vertica;SERVER=vertica1;DATABASE=abc;PORT=5433;UID=;PWD=']
    conn = pyodbc.connect(x[random.randint(0,1)])
    cursor.execute(queries)
    rows = cursor.fetchall()
    print 'done'
    return rows[0]

pool = ThreadPool(2)
results = pool.map(run_queries_diff, queries)
print time.time() - start_time

我收到了这个错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>

    return self.map_async(func, iterable, chunksize).get()

    raise self._value
pyodbc.Error: ('HY000', 'The driver did not supply an error!')

0 个答案:

没有答案