简体   繁体   English

使用 adodbapi 在 python 中创建到 Vertica 数据库的连接

[英]Creating a connection to Vertica database in python using adodbapi

Does anyone know what are the parameters for creating a connection string to Vertica database using adodbapi?有谁知道使用 adodbapi 创建到 Vertica 数据库的连接字符串的参数是什么? I cannot use pyodbc, because it does not work with IronPython.我不能使用 pyodbc,因为它不适用于 IronPython。

I have tried:我努力了:

    connectorsver = ["DRIVER=Vertica ODBC Driver 4.1"]
    connectorsver.append("SERVER=1.1.1.1\xx")
    connectorsver.append ("DATABASE=mydatabase")
    connectorsver.append ("User Id=dbadmin")
    connectorsver.append ("Password=xxx")
            con = adodbapi.connect(";".join (connectorsver)) 

and that returned an operational error.并且返回了一个操作错误。 The same technique with an MSSQL connection string worked fine.使用 MSSQL 连接字符串的相同技术效果很好。 When I created a DSN in Windows with this information, it also made a successful connection to vertica.当我使用此信息在 Windows 中创建 DSN 时,它也成功连接到了 vertica。

Any help is appreciated.任何帮助表示赞赏。

Looking at the Unit Tests for ADODBAPO , connect() will raise an adodbapi.DatabaseError on failure. 查看 ADODBAPO 的单元测试connect()将在失败时raise adodbapi.DatabaseError You should check for this exception:您应该检查此异常:

try:
    con = adodbapi.connect(";".join (connectorsver))
except adodbapi.DatabaseError, e:
    print e

Watch your indentation, too.也要注意你的缩进。 It looks like you're mixing tabs and spaces.看起来您正在混合制表符和空格。 Python's very sensitive to such things. Python 对这些东西非常敏感。

I've not used Vertica, but you may find answers to does anyone know the format of an odbc connection string for vertica?我没有使用过 Vertica,但您可能会找到答案, 是否有人知道 Vertica 的 odbc 连接字符串的格式? to be of interest.感兴趣。

Hope this helps.希望这可以帮助。

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

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