We have been asked to add Python to the mix of software we are using. SPDS has been a central Database server for a long time and it works well with Base SAS but we have had a request to allow python connections.
I am wondering about the best route and connection strings to support our python users in a Base SAS environment.
Thanks.
If it's enought to access data throgh SQL, you should be able to connect to SPDS own ODBC driver connection.
If you want to submit SAS code, you need to conenct to a SAS session that has SPDS libnames available. Here check the documentation for SASPy.
Did you follow all these steps? https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/spdsug/p0d2bbuq1jkfnun1ksjw86cy5kfn.htm
Hmmm.... If this works out of R etc. but the message is "SAS ODBC Driver not capable" then it's may-be also worth to contact SAS TechSupport.
SASPy should work as well - also for writing data to SPDS. Method sasdata2dataframe should allow to load SPDS tables into a dataframe.
We've built an open-source server for Base SAS - which comes with a full REST API.
You could easily spin this up and trigger a Stored Program (SAS code that queries your SPD tables) using the `/SASjsApi/stp/execute` endpoint.
Happy to jump on a call to help you get set up - we haven't documented the multi-user capability yet: https://github.com/sasjs/server
Thank you for all of your responses so far - the community is great.
We have pyodbc working now for read access. It required the autocommit=True option to be set. It spins out a number of errors but the connection works. There was a suggestion to use sqlAlchemy but there is no "dialect" information (that we could find) for SPDS.
We have also been looking at saspy as that seemed like a good solution but getting it to work in our environment has worked out (yet).
import pyodbc
import os
cnxn = pyodbc.connect('dsn=spds.DOMAIN; uid=XXXXXX)'; pwd=XXXXX'), autocommit=True)
Output:
05/12/22 16:42:33:(5480) SPDS- Message file spdsmsg.m open failed: errno=2
05/12/22 16:42:33:(5480) SPDS- Message file wglobal.m open failed: errno=2
05/12/22 16:42:33:(5480) SPDS- Message file engmsg.m open failed: errno=2
05/12/22 16:42:33:(5480) SPDS- Message file sqlmsg.m open failed: errno=2
05/12/22 16:42:33:(5480) SPDS- Message file supmsg.m open failed: errno=2
05/12/22 16:42:33:(5480) SPDS- Message file sqlmsob.m open failed: errno=2
05/12/22 16:42:33:(5480) SPDS- Message file xffile.m open failed: errno=2
05/12/22 16:42:33:(5480) SPDS- Message file zsem.m open failed: errno=2
05/12/22 16:42:33:(5480) SPDS- Message file dates.m open failed: errno=2
05/12/22 16:42:33:(5480) SPDS- Message file wxmsg.m open failed: errno=2
05/12/22 16:42:33:(5480) SPDS- Message file attrbm.m open failed: errno=2
05/12/22 16:42:33:(5480) SPDS- Message file hdpmsg.m open failed: errno=2
***MESSAGE NOT FOUND***
***MESSAGE NOT FOUND***
SPDS_NOTE: User SPDSUSER(ACL Group EXTERNAL) connected to SPD(NT) 5.4 Server at XXX.XXX.XXX.X.
SPDS_NOTE: Libref X0000001 was successfully assigned as follows:
Engine: SPDSENG
Physical Name: :5420m:\meta\XXXXX\
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.