Using saspy I am trying to connect to a teradata server using the saslib method. I have my username and password stored in a credentials file that I am referencing from an import statement and storing username and password as a python object.
When I reference username and password in the saslib method one of the symbols in my password appears to be escaping the string and trying to resolve. The special character is the '@' symbol. Is there a way to fix this?
I am using python 3.5.2 in a UNIX environmet and sas 9.4 on the grid
Code:
import saspy
from CONFIG.sasconfig import username, password
sas = saspy.SASsession(omruser=username, omrpw=password, cfgname='configname')
sas.saslib('rpt', engine='Teradata', options='user='+username+' pw='+password+' server=server1 schema=schema1')
error:
libname rpt Teradata user=myusername pw=XXXX@XXXX server=server1 schema=schema1;
_
22
ERROR: Libref RPT is not assigned.
ERROR: Error in the LIBNAME statement.
ERROR 22-7: Invalid option name @.
Hey, I think you can just quote the pw and it ought to work. Give this a try:
sas.saslib('rpt', engine='Teradata', options='user='+username+' pw="'+password+'" server=server1 schema=schema1')
Hopefully that's all you need.
Tom
I replied, but it seems to have gone into the ether.
You need to put the password in quotes. You can probably just put double quotes inside the existing single quotes; in SAS you would use quote(trim(password)), but I don't know the Python equivalent.
You're on a grid system? Consider using an authdomain instead.
Hey, I think you can just quote the pw and it ought to work. Give this a try:
sas.saslib('rpt', engine='Teradata', options='user='+username+' pw="'+password+'" server=server1 schema=schema1')
Hopefully that's all you need.
Tom
That did the trick! Thanks for the help.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.