0

I'm trying to create a connection with Primavera Software development Kit on windows 10 64 bit using Python 2.7 32 bit (sadly Primavera's SDK is available only for 32 bit) and using comtypes module.

The effective part of my code is

#Needed Imports
import sys
import os
import comtypes.client
from comtypes.client import CreateObject

#Create the ADO Object, then connect to Primavera's Database,
#supplying the "ConnectionString" as an argument to the method "Open".
SDK = CreateObject('ADODB.Connection')
SDK.Open("DRIVER={Primavera Software Development Kit};DSN=PMSDK;UID=pubuser;PWD=pubuser")

And the error is at the line

SDK.Open("DRIVER={Primavera Software Development Kit};DSN=PMSDK;UID=pubuser;PWD=pubuser")

Though the SDK is configured with the 32-bit ODBC tool as shown in these images:

SDK added as a Data Source named PMSDK

Properties of PMSDK at ODBC Configuration

But whatever I do with the ConnectionString, I always face this error

COMError: (-2147467259, 'Unspecified error', (u'[ATI][OpenRDA ODBC]General error - Database keyword not present in the connect string', u'Microsoft OLE DB Provider for ODBC Drivers', None, 0, None))

What should be done so as to get python recognizing Primavera's Software Development Kit?!


EDIT

changing the ConnectionString to DRIVER={Primavera Software Development Kit};DSN=PMSDK;DATABASE=C:\Oracle\Primavera P6\PMSDK\Drivers;UID=pubuser;PWD=pubuser or to DRIVER={Primavera Software Development Kit};SERVER=127.0.01;DSN=PMSDK;DATABASE=C:\Oracle\Primavera P6\PMSDK\Drivers;UID=pubuser;PWD=pubuser results into this error

COMError: (-2147467259, 'Unspecified error', (u'[ATI][OpenRDA ODBC]RDA error: Resource unknown - Database Name:C:\\Oracle\\Primavera P6\\PMSDK\\Drivers is not valid on Server.', u'Microsoft OLE DB Provider for ODBC Drivers', None, 0, None))
  • This is the Error with python 2.7 64 bit `COMError: (-2147467259, 'Unspecified error', (u'[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified', u'Microsoft OLE DB Provider for ODBC Drivers', None, 0, None))` – Serag Hassouna Sep 27 '17 at 18:48

1 Answers1

1

What a weird (or rather simple) route to get that connection.

Simply, the ConnectionString must be:

"DRIVER={Primavera Software Development Kit};DSN=PMSDK;DATABASE=PMSDK;UID=myuid;PWD=mypwd"

Where you have to replace myuid and mypwd with the username and the password entered when you regularly open Primavera at this welcome screen

Welcome Screen


Bear in mind that this issue results from a simple test on how to connect to Primavera's Software Development Kit on python 2.7 (works only with 32 bit installation), so if you try to use python 64 bit, you have to face the sad fact to install the 32 bit version, and also you have to reinstall all needed packages/extensions for this newly installed version.

i.e. I have comtypes already installed during my work with the 64 bit version, but in order to make the code run I have had to install it again solely for the 32 bit version.

You have to create a separate folder for your new python 32 bit installation, name it e.g. Python27_32, and chose it when asked during the installation.

After that, To install packages with the pip utility or with setup.py files for your 32 bit version, you need to run python from its specific folder, hence, no python -m pip install <package>, it would be instead C:\Python27_32\python.exe -m pip install or C:\Python27_32\python.exe setup.py install