2010-04-23 105 views
3

我的公司使用Vertica。我們有pyodbc連接到它的Python應用程序。我在Mac(Snow Leopard)上完成了大部分開發工作,不幸的是,Vertica還沒有發佈Mac版的ODBC驅動程序。但他們確實有JDBC驅動程序。我不認爲在Jython中開發是一個很好的折衷方案。有沒有辦法使用ODBC驅動程序使用JDBC驅動程序?某種類型的ODBC連接器?在JDBC驅動程序中使用ODBC應用程序

回答

4

編輯:更新Vertica的5/6可以在這裏找到https://github.com/serbaut/psycopg2

這裏有一個補丁,使psycopg2 2.2.1工作,Vertica的4.0。不需要ODBC。

diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c 
index 902fdbb..b07eee8 100644 
--- a/psycopg/connection_int.c 
+++ b/psycopg/connection_int.c 
@@ -280,6 +280,10 @@ conn_setup(connectionObject *self, PGconn *pgconn) 
     pgres = psyco_exec_green(self, psyco_datestyle); 
    } 

+ if (self->server_version == 0 && self->protocol == 3) { /* vertica */ 
+  self->encoding = strdup("UTF8"); 
+  self->isolation_level = 0; 
+ } else { 
    if (pgres == NULL || PQresultStatus(pgres) != PGRES_COMMAND_OK) { 
     PyErr_SetString(OperationalError, "can't set datestyle to ISO"); 
     IFCLEARPGRES(pgres); 
@@ -335,7 +339,7 @@ conn_setup(connectionObject *self, PGconn *pgconn) 
     return -1; 
    } 
    self->isolation_level = conn_get_isolation_level(pgres); 
- 
+ } 
    Py_UNBLOCK_THREADS; 
    pthread_mutex_unlock(&self->lock); 
    Py_END_ALLOW_THREADS; 
diff --git a/psycopg/typecast_builtins.c b/psycopg/typecast_builtins.c 
index e8e5a1a..45b9dbc 100644 
--- a/psycopg/typecast_builtins.c 
+++ b/psycopg/typecast_builtins.c 
@@ -1,15 +1,15 @@ 
static long int typecast_NUMBER_types[] = {20, 23, 21, 701, 700, 1700, 0}; 
-static long int typecast_LONGINTEGER_types[] = {20, 0}; 
+static long int typecast_LONGINTEGER_types[] = {6, 20, 0}; 
static long int typecast_INTEGER_types[] = {23, 21, 0}; 
-static long int typecast_FLOAT_types[] = {701, 700, 0}; 
-static long int typecast_DECIMAL_types[] = {1700, 0}; 
-static long int typecast_UNICODE_types[] = {19, 18, 25, 1042, 1043, 0}; 
+static long int typecast_FLOAT_types[] = {7, 701, 700, 0}; 
+static long int typecast_DECIMAL_types[] = {16, 1700, 0}; 
+static long int typecast_UNICODE_types[] = {8, 9, 19, 18, 25, 1042, 1043, 0}; 
static long int typecast_STRING_types[] = {19, 18, 25, 1042, 1043, 0}; 
-static long int typecast_BOOLEAN_types[] = {16, 0}; 
-static long int typecast_DATETIME_types[] = {1114, 1184, 704, 1186, 0}; 
-static long int typecast_TIME_types[] = {1083, 1266, 0}; 
-static long int typecast_DATE_types[] = {1082, 0}; 
-static long int typecast_INTERVAL_types[] = {704, 1186, 0}; 
+static long int typecast_BOOLEAN_types[] = {5, 0}; 
+static long int typecast_DATETIME_types[] = {12, 13, 1114, 1184, 704, 1186, 0}; 
+static long int typecast_TIME_types[] = {11, 15, 1083, 1266, 0}; 
+static long int typecast_DATE_types[] = {10, 1082, 0}; 
+static long int typecast_INTERVAL_types[] = {14, 704, 1186, 0}; 
static long int typecast_BINARY_types[] = {17, 0}; 
static long int typecast_ROWID_types[] = {26, 0}; 
static long int typecast_LONGINTEGERARRAY_types[] = {1016, 0}; 
+0

我只是假設這回答了這個問題。儘管如此,我還是無法驗證,因爲我很久沒有需要Vertica了。 – 2012-10-10 01:29:22

1

是的,有ODBC-over-JDBC橋接器。其中包括OpenLink,其中一款適用於Mac OS。

+0

我希望豹發行工作在雪豹 – 2010-04-23 08:16:44

+0

嗯,我怎麼用這個東西? – 2010-04-23 21:22:17

+0

我還沒試過。但是,該產品包含基本支持(http://support.openlinksw.com/supportweb/SupportServicesFAQ#SupportContractNeeded)。 – 2010-04-24 01:48:40