Connect to ASE sybase in Robotframework using databaseLibrary - robotframework

I'm trying to connect to Sysbase but i have always the error
Suite setup failed:
OperationalError: ('08001', u"[08001] [Microsoft][ODBC SQL Server
Driver][DBNETLIB]Ce serveur SQL n'existe pas ou son acc\xe8s est
refus\xe9. (17) (SQLDriverConnect); [08001] [Microsoft][ODBC SQL
Server Driver][DBNETLIB]ConnectionOpen (Connect()). (53)")
My code is:
*** Settings ***
Suite Setup Connect To Database pyodbc ${DBName} ${DBUser}
${DBPass} ${DBHost} ${DBPort}
Suite Teardown Disconnect From Database
Library Selenium2Library
Resource ../../../Keywords/Initialisation/Initialisation.robot
Library DatabaseLibrary
Library OperatingSystem
*** Variables ***
${DBHost} ""
${DBName} ""
${DBPass} ""
${DBPort} ""
${DBUser} ""
*** Test Cases ***
Récupérer CAB
${output} = Execute SQL String select "" from "" where ""= '80000204000048' ;
Log ${output}
I have installed databaselibrary
pip install robotframework-databaselibrary and pyodbc
">pip install pyodbc"

Related

Connecting remote windows machine using Robot Framework

I need to connect to a remote WINDOWS server machine and create a folder and download some files in that folder in remote machine.
I tried with this WinRMLibrary, however getting the below error. Is there any options or other libraries to achieve this functionality in Robot Framework?
Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000008EC69AAA90>: Failed to establish a new connection: [Errno 110061] failed'));
Anybody faced similar issue and find solutions for the same?
*** Settings ***
Library WinRMLibrary
*** Test Cases ***
Get ip on windows host
Create Session server windows-host Administrator 1234567890
${params}= Create List "download_files"
${result}= Run cmd server mkdir ${params}
Log ${result.status_code}
Log ${result.std_out}
Log ${result.std_err}

[DataDirect][ODBC lib] Driver Manager Message file not found. Please check for the value of InstallDir in your odbc.ini in Informatica

I am using informatica, I have Singlestore DB which I am trying to connect.
I am able to login to singelstore DB using Singlestore ODBC Driver as below.
Singlestore version:8.0.5
SS ODBC Driver version: 1.1.1
Singlestore is self managed.
[abc#rnd-2 ~]$ isql SingleStore-server
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> ^C
While I am trying to connect informatica with Singlestore using ODBC Connection, I am gettion error:
Message Code: WRT_8001
Message: Error connecting to database...
WRT_8001 [Session s_test Username dev DB Error -1
[DataDirect][ODBC lib] Driver Manager Message file not found. Please check for the value of InstallDir in your odbc.ini.
Database driver error...
Function Name : Connect
Database driver error...
Function Name : Connect
Database Error: Failed to connect to database using user [dev] and connection string [SingleStore-server].]Message Code: WRT_8001
Message: Error connecting to database...
WRT_8001 [Session s_test Username dev DB Error -1
[DataDirect][ODBC lib] Driver Manager Message file not found. Please check for the value of InstallDir in your odbc.ini.
Database driver error...
Function Name : Connect
Database driver error...
Function Name : Connect
Database Error: Failed to connect to database using user [dev] and connection string [SingleStore-server].]
My location of odbc.ini file: /etc/odbc.ini
odbc.ini
[SingleStore_server]
Description=SingleStore server
Driver=/home/abc/singlestore-connector-odbc-1.1.1-centos7-amd64/libssodbca.so
SERVER=<>
USER=<>
PASSWORD=<>
DATABASE=<>
PORT=<>
I added path in .bash_profile, but still getting same error:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export ODBCINI=/etc/odbc.ini
Pls let me know how to resolve this error.
Ref link: https://knowledge.informatica.com/s/article/577839?language=en_US
https://knowledge.informatica.com/s/article/Error-connecting-to-database-DataDirect-ODBC-lib-Driver-Manager-Message-file-not-found-Please-check-for-the-value-of-InstallDir-in-your-odbc-ini-while?language=en_US
https://docs.singlestore.com/managed-service/en/developer-resources/connect-with-application-development-tools/connect-with-odbc/the-singlestore-odbc-driver.html
Reg export ODBCINI=/etc/odbc.ini, I have seen Informatica always use their ODBC drivers. Can you please check if you have single store drivers available in /<INFA_HOME>/ODBCX.version/odbc.ini​ file? If yes, i highly recommend to use it.
If yes, please see if you can test the ODBC driver with Infa provided tool $INFA_HOME/tools/debugtools/ssgodbc -d dsn -u username -p password [-v] against your DB. This will ensure you have no issues with ODBC setup.
You can find all about this here link.
If no, then, pls make sure you have installed correct version single store ODBC drivers (32 or 64 bit) and Informatica user have RWX permission on them. Then,
Add the driver path to LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$HOME/server_dir:$ODBCHOME/lib;
set ODBCINI=/etc/odbc.ini
grant access - chmod 777 /etc/odbc.ini
see if the tool ssgodbc is able to establish connection.
Please see the following examples of integrating SingleStore data with Informatica:
JDBC - https://www.cdata.com/kb/tech/singlestore-jdbc-informatica-cloud.rst
ODBC - https://www.cdata.com/kb/tech/singlestore-odbc-informatica.rst

Connecting to teradata using DBI R package

I am trying to connect to Teradata database from R terminal using code below,
"> con <- DBI::dbConnect(odbc::odbc(),
+ Driver = "Teradata",
+ Host = "xxxx",
+ DBCName = "xxxx",
+ UID = "xxxx"
+ )"
I have created /etc/odbc.ini and /etc/odbcinst.ini and below are the contents of the same,
odbc.ini:
[ODBC]
InstallDir=/opt/teradata/client/16.20/odbc_64
DataEncryption='ON'
[ngmtdd01]
Driver=/opt/teradata/client/16.20/odbc_64/lib/tdataodbc_sb64.so
Description=Teradata Dev
DBCName=xxxx.dev.uk.capitalone.com
LoginTimeout=120
odbcinst.ini
[ODBC DRIVERS]
Teradata Database ODBC Driver 16.20=Installed
[Teradata Database ODBC Driver 16.20]
Driver=/opt/teradata/client/16.20/odbc_64/lib/tdataodbc_sb64.so
APILevel=CORE
ConnectFunctions=YYY
DriverODBCVer=3.51
SQLLevel=1
I expected to get connected to the teradata cli but I am getting below error.
Error: nanodbc/nanodbc.cpp:950: IM002: [DataDirect][ODBC lib] Data source name not found and no default driver specified"
You defined a DSN but your connection string is "DSN-less" (using Driver= not DSN=) and Driver= specifies the wrong driver name; the actual name is Teradata Database ODBC Driver 16.20
Note that Teradata also supplies a Teradata SQL Driver for R package that does not require ODBC.

Unable to connect to mysql db via robotframework

I am trying to connect MySQL DB in robot framework. But I am receiving the following error:
Operational Error: (1045, u"Access denied for user
'ABC'#'Nd204-151-102-92.com' (using password: YES)")
I have used the Database Library and the following code :
*** Settings ***
Library Database Library
Library pymysql
*** Variable ***
${DBHost} value4
${DBName} value1
${DBPass} "value2"
${DBPort} port
${DBUser} value3
*** Keywords ***
Connect to DB
Connect To Database pymysql ${DbName} ${DBUser} ${DBPass}
${DBHost} ${DBPort}
${output}= Query select * from tables;
I'm going to go out on a limb and guess that you're adding quote marks around your username and password. The error message seems to imply this, and you added the following in a comment:
I am defining the username and password and in my variables section in the same robot file : like under*** Variables *** ${DBUser} = 'DBuser' and ${DBPass} = 'dbpassword'
Assuming the username is the six character string DBuser and the password is the 10 character string dbpassword, you need to define it like this:
*** Variables ***
${DBUser} DBuser
${DBPASS| dbpassword
Notice the lack of an =, and there are no quotes.

Robotframework and SSHLibrary issue with a network router

I am now trying to use SSHLibrary to ssh into a virtual router running on my PC and execute a simple ping test on the router and then present the result of the test case.
I can login to the router and also execute the command outside of the robotframework, but when I try to do this using robotframework I get a fail with an error message and not sure how i solve for this error message:
Here is my robotframework test script:
*** Settings ***
Library SSHLibrary
Suite Setup Open Connection And Log In
Suite Teardown Close All Connections
*** Variable ***
${HOST} 172.31.1.250
${USERNAME} admin
${PASSWORD} admin
*** Keywords ***
Open Connection And Log In
Open Connection ${HOST}
Login ${USERNAME} ${PASSWORD}
*** Test Cases ***
Ping test
${output} = Execute Command ping 1.1.1.1
Should Contain ${result.stdout} 64 bytes from 1.1.1.1
Here is the output I get when I execute the above test case:
==============================================================================
Sros
==============================================================================
Ping test | FAIL |
ChannelException: (1, 'Administratively prohibited')
------------------------------------------------------------------------------
Sros | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
What is this error message and how do I solve this:
**ChannelException: (1, 'Administratively prohibited')**
Does it matter what type of the router that I am login into is?
Thanks for your help.
Based on the feedback I have changed from Execute Command to Write.
So my script looks like this now:
*** Settings ***
Library SSHLibrary
Suite Setup Open Connection And Log In
Suite Teardown Close All Connections
*** Variable ***
${HOST} 172.31.1.250
${USERNAME} admin
${PASSWORD} admin
*** Keywords ***
Open Connection And Log In
Open Connection ${HOST}
Login ${USERNAME} ${PASSWORD}
*** Test Cases ***
Ping test
${result} = Write ping 1.1.1.1 count 1
Should Contain ${result.stdout} 64 bytes from 1.1.1.1
But now I get following error message:
==============================================================================
Sros
==============================================================================
Ping test | FAIL |
Resolving variable '${result.stdout}' failed: AttributeError: 'str' object has no attribute 'stdout'
------------------------------------------------------------------------------
Sros | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Also not I have checked using Wireshark that robot script does actually ssh into the router and establish a ssh session. I think the connectivity part of working fine.
Consider using
Write ping 1.1.1.1
${output}= Read delay=0.5s
to get the output in a var. It will now have the same behavior you have while doing it manually !
I hope it will help you ;)

Resources