Hello,
has anyone tried running a multithreaded python app using pyodbc ?
I found that the program below serializes at second db2.cursor call in either ODBC or pyodbc so that parallelism is lost . Any ideas where the culprit is ?
This is running on vertica 6.1.3 with 6.1.3 linux drivers on unixODBC 2.2.14
#!/usr/local/bin/python
import sys, io, os, datetime, pyodbc, threading, time
# db login info
dsn = 'VerticaDSN';password = '...';
def test():
db = pyodbc.connect("DSN=%s;PWD=%s" % (dsn, password));
cursor = db.cursor()
print "first query"
cursor.execute("create table temp.tn_foo2 as select * from ... limit 10000000;")
print "first query finished"
def test2():
print "running second query"
db2 = pyodbc.connect("DSN=%s;PWD=%s" % (dsn, password));
cursor2 = db2.cursor() cursor2.execute("select count(*) from ...;")
print "second finished"
print "starting thread"t=threading.Thread(target = test)
t.start()
time.sleep(1)
print "starting thread 2"t=threading.Thread(target = test2)
t.start()
Thanks,
Sign up
Already have an account? Login
Welcome to the Rocket Forum!
Please log in or register:
Employee Login | Registration Member Login | RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.