【问题标题】:Using an ODBC application with a JDBC driver将 ODBC 应用程序与 JDBC 驱动程序一起使用
【发布时间】:2011-02-11 08:19:56
【问题描述】:

我的公司使用Vertica。我们有使用 pyodbc 连接到它的 Python 应用程序。我的大部分开发工作都是在 Mac (Snow Leopard) 上完成的,不幸的是 Vertica 尚未发布适用于 Mac 的 ODBC 驱动程序。他们确实有 JDBC 驱动程序。我不认为在 Jython 中进行开发是一个好的折衷方案。有什么方法可以将 JDBC 驱动程序与 ODBC 应用程序一起使用?某种 ODBC 连接器?

【问题讨论】:

    标签: jdbc odbc pyodbc vertica


    【解决方案1】:

    编辑: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};
    

    【讨论】:

    • 我只是假设这回答了这个问题。不过我无法验证它,因为我已经很长时间不需要 Vertica。
    【解决方案2】:

    是的,有 ODBC-over-JDBC 桥。 OpenLink 等为 Mac OS 提供了一个。

    【讨论】:

    【解决方案3】:

    从 Vertica 6 开始,https://my.vertica.com 门户网站提供适用于 Mac OS X 的本机 ODBC 驱动程序

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-05
      • 2013-06-24
      • 2013-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多