Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7398673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:53:58+00:00 2026-05-29T03:53:58+00:00

I am using pyodbc to manage my database connections. I am attempting to connect

  • 0

I am using pyodbc to manage my database connections. I am attempting to connect to an OSI PI database and receive this error:

pyodbc.Error: ('IM002', "[IM002] [OSI][PI ODBC][PI]PI-API Error <pilg_getdefserverinfo> 0 (0) (SQLDriverConnectW); [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr). (0)")

After talking with the vendor, I got this response:
Looks like pyodbc is written against ODBC 3.x. The OSI PI ODBC driver is using ODBC 2.0. The python ODBC driver manager will convert most ODBC 3 calls on the fly to ODBC 2 ones. Anything added to 3, however, will obviously fail. You would need to find some way to make sure that your only using 2.0 compliant ODBC calls. Currently their is not a PI ODBC driver that is compliant with ODBC 3.0.

My code is fairly simple as I’m just attempting to connect at this point:

import pyodbc
constr = 'DRIVER={PI-ODBC};SERVER=myserver;UID=MY_UID'
pyodbc.pooling=False
conn = pyodbc.connect(constr)           # Error at this line
conn.close()

Has anyone connected python to OSI PI? If so, how did you do so? If not and you still used data in the OSI database, how did you end up accessing it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:53:59+00:00Added an answer on May 29, 2026 at 3:53 am

    I figured out how to do this. I had to change from using pyodbc though. Instead, I’m doing this with win32com.

    Example

    from win32com.client import Dispatch
    
    oConn = Dispatch('ADODB.Connection')
    oRS = Dispatch('ADODB.RecordSet')
    
    oConn.ConnectionString = "Provider=PIOLEDB;Data Source=<server>;User ID=<username>;database=<database>;Password=<password>"
    oConn.Open()
    
    if oConn.State == 0:
        print "We've connected to the database."
        db_cmd = """SELECT tag FROM pipoint WHERE tag LIKE 'TAG0001%'"""
        oRS.ActiveConnection = oConn
        oRS.Open(db_cmd)
        while not oRS.EOF:
            #print oRS.Fields.Item("tag").Value   # Ability to print by a field name
            print oRS.Fields.Item(0).Value        # Ability to print by a field location
            oRS.MoveNext()
        oRS.Close()
        oRS = None
    else:
        print "Not connected"
    
    if oConn.State == 0: 
        oConn.Close()
    oConn = None
    

    Notes:

    • This requires the PIOLEDB driver provided by OSISoft is installed on the machine that runs this code.
    • Performance doesn’t seem horrible with this method. I was able to pull back several hundred thousand records with some of my other queries and it returned in an acceptable amount of time
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using pyodbc to connect to various odbc compliant databases. Suppose a MySql
Periodically when using pyodbc to create a connection to an oracle database, it kills
I am currently selecting a large list of rows from a database using pyodbc.
I'm using pyodbc to data-mine a big database in a .mbd (access) file. I
I'm using pyodbc to query to an SQL Server database import datetime import pyodbc
Im trying to use Spyder with pyodbc to connect mysql using a PyQT4 gui
I trid the following code, import pyodbc try: pyodbc.connect('DRIVER={%s};SERVER=%s;DATABASE=%s;UID=%s;PWD=%s' % (driver, server, database, uid,
I'm using pyodbc to query a SQL Server 2008 database table with columns of
I am trying to query ODBC compliant databases using pyodbc in ubuntu . For
I'm runing into Memory Error Using python 2.6, pyodbc The code loops through several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.