Getting Below Error
OperationalError: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. (17) (SQLDriverConnect); [08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). (53)'
*** Settings ***
Documentation Simple example using DBLibrary.
Library SeleniumLibrary
Library DatabaseLibrary
*** Variables ***
${DBHost_ConnectionString} 'DRIVER={SQL Server};SERVER="hostname";UID="uname";PWD="******";DATABASE="dbname"'
*** Test Cases ***
Connect Database
Connect To Database Using Custom Params pyodbc ${DBHost_ConnectionString}
I tried all the solutions over internet, like adding port to connection string, appending tcp before servername, e.t.c,
Followed the implementation mentioned in the source code of dbapi
https://github.com/franz-see/Robotframework-Database-Library/blob/master/src/DatabaseLibrary/connection_manager.py
elif dbapiModuleName in ["pyodbc", "pypyodbc"]:
dbPort = dbPort or 1433
logger.info('Connecting using : %s.connect(DRIVER={SQL Server};SERVER=%s,%s;DATABASE=%s;UID=%s;PWD=%s)' % (dbapiModuleName, dbHost, dbPort, dbName, dbUsername, dbPassword))
self._dbconnection = db_api_2.connect('DRIVER={SQL Server};SERVER=%s,%s;DATABASE=%s;UID=%s;PWD=%s' % (dbHost, dbPort, dbName, dbUsername, dbPassword))
Any help should be appreciated.
As a guess, you shouldn't surround your connection string with single quotes, as they become part of the connection string. Robot is not python, and robot is not the shell, so you don't normally need to quote strings.
*** Variables ***
${DBHost_ConnectionString} DRIVER={SQL Server};SERVER="hostname";UID="uname";PWD="******";DATABASE="dbname"
It's not clear if you're literally using the string hostname and uname, etc., or if that's just boilerplate for the purpose of the question. You need to be passing the actual hostname and actual username and password.
You may not need the quotes around the other values, in which case it would look like this:
*** Variables ***
${DBHost_ConnectionString} DRIVER={SQL Server};SERVER=hostname;UID=uname;PWD=******;DATABASE=dbname
Related
I got the following error in the database manager DBeaver 22.1.4 on the informix database:
SQL-Error [IX000]: Connection not established
Strangely if i make a select only on this table i got the error above. But if i make a select on all other tables the select has an result.
The full error message you find here:
org.jkiss.dbeaver.model.impl.jdbc.JDBCException: SQL-Error [IX000]: Connection not established
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl.prepareStatement(JDBCConnectionImpl.java:197)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl.prepareStatement(JDBCConnectionImpl.java:1)
at org.jkiss.dbeaver.model.DBUtils.createStatement(DBUtils.java:1391)
at org.jkiss.dbeaver.model.DBUtils.makeStatement(DBUtils.java:1359)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeStatement(SQLQueryJob.java:553)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.lambda$1(SQLQueryJob.java:486)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:172)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeSingleQuery(SQLQueryJob.java:493)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.extractData(SQLQueryJob.java:894)
at org.jkiss.dbeaver.ui.editors.sql.SQLEditor$QueryResultsContainer.readData(SQLEditor.java:3643)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:118)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:172)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:116)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:4945)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:105)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.sql.SQLException: Connection not established
at com.informix.util.IfxErrMsg.buildExceptionWithMessage(IfxErrMsg.java:416)
at com.informix.util.IfxErrMsg.buildException(IfxErrMsg.java:397)
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:371)
at com.informix.jdbc.IfxStatement.<init>(IfxStatement.java:134)
at com.informix.jdbc.IfxPreparedStatement.<init>(IfxPreparedStatement.java:116)
at com.informix.jdbc.IfxSqliConnect.prepareStatement(IfxSqliConnect.java:5902)
at com.informix.jdbc.IfxSqliConnect.prepareStatement(IfxSqliConnect.java:2367)
at com.informix.jdbc.IfxSqliConnect.prepareStatement(IfxSqliConnect.java:101)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl.prepareStatement(JDBCConnectionImpl.java:244)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl.prepareStatement(JDBCConnectionImpl.java:146)
... 15 more
Have somebody an idea?
Anybody that actually got this to work? To use a csv-file as a datasource with polybase? I've just get the error message below.
Msg 105082, Level 16, State 1, Line 12. See the rest in code block.
Got the latest updates both of SQL Server 2019 EE, OS and ODBC and Microsoft Access Text Driver. The user has the right credentials. Creating the external data source is no problem, it's when trying creating the external table the error occurs. Can anybody see the any obvious error
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'TOPSECRET_PSW';
GO
CREATE EXTERNAL DATA SOURCE TestCSV
WITH
(
LOCATION = 'odbc://localhost',
CONNECTION_OPTIONS = 'Driver=Microsoft Access Text Driver (*.txt, *.csv);Dbq=D:\APA\',
PUSHDOWN = OFF
);
CREATE EXTERNAL TABLE dbo.testCSV
(
Header1 nvarchar(128)
,Header2 nvarchar(128)
)
WITH
(
LOCATION='[testCSV.csv]',
DATA_SOURCE = TestCSV
)
Msg 105082, Level 16, State 1, Line 12
105082;Generic ODBC error: [Microsoft][ODBC Text Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x1608 Thread 0x3450 DBC 0x8d76d578 Text'. Additional error <2>: ErrorMsg: [Microsoft][ODBC Text Driver]Invalid connection string attribute SERVER, SqlState: 01S00, NativeError: 8 Additional error <3>: ErrorMsg: [Microsoft][ODBC Text Driver]Invalid connection string attribute SERVER, SqlState: 01S00, NativeError: 8 Additional error <4>: ErrorMsg: [Microsoft][ODBC Text Driver]Invalid connection string attribute SERVER, SqlState: 01S00, NativeError: 8 Additional error <5>: ErrorMsg: [Microsoft][ODBC Text Driver]Invalid connection string attribute SERVER, SqlState: 01S00, NativeError: 8 .
You need to apply latest SQL Server 2019 CU to get rid of that message. However, once that error disappears, I couldn't make it work on Docker, are you using a physical machine?
I am working off of a server housing various SQL databases (accessed via Microsoft SQL Server Management Studio) and am going to use R to perform analyses and explore a specific database within the server. I have network security that permits communication between machines, drivers installed on the R server, and RODBC installed.
When I attempt to establish a Windows ODBC connection in the Control panel>Administrative>Data Sources, I can only add a data source for the entirety of the SQL server, not just for the specifc database I want to look at. I pasted the code I have been experimenting with below.
library(RODBC)
channel <- odbcConnect("Example", uid="xxx", pwd=****");
sqlTables(channel)
sqlTables(ch, tableType = "TABLE")
res <- sqlFetch(ch, "samp.le", max = 15) #not recognizing as a table
library(RODBC)
ch <- odbcDriverConnect('driver={"SQL Server"}; server=Example; database=dbasesample; uid="xxxx", pwd = "****"')
Response: Warning messages:
1: In odbcDriverConnect("driver={\"SQL Server\"}; server=sample; database=dbasesample; uid=\"xxxx", pwd = \"xxxx\"") :
[RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
2: In odbcDriverConnect("driver={\"SQL Server\"}; server=sample; database=dbasesample; uid=\"xxxx\", pwd = \"xxxx!\"") :
ODBC connection failed
Any insight into this issue would be much appreciated.
Although while querying with the sqlQuery() function you can specify database, schema and table, e.g.
library(RODBC)
con = odbcConnect(dsn = 'local')
sample_query = sqlQuery(con,'select * from db.dbo.table')
I have not found a way to define the database from within the function parameters while using sqlFetch() or sqlSave(). An indirect way would be to define the default database in the dsn (as written in the comments). But then, you would need a different dsn for each database you would like to use.
A better solution would be to use the odbc and DBI packages instead of RODBC, and define the database in the connection statement e.g.
library(dplyr)
library(DBI)
library(odbc)
con <- dbConnect(dsn = 'local',database = 'db')
copy_to(con, rr2, temporary = F)
By the way, I found copy_to to be much faster than the equivalent sqlSave of RODBC.
I am successfully querying what I need from the first Server with the following:
library(RODBC)
library(data.table)
library(sqldf)
library(zoo)
library(forecast)
library(plyr)
library(parallel)
myconn <- odbcDriverConnect("SERVER=SQL12p4;DRIVER=SQL Server")
ManagementHours <- sqlQuery(myconn, " SELECT .......")
However when I try to connect to a different server SQL12P4\VSQL1 I am unable to connect. I know that the \ is an escape character and I believe that is my problem. I am wondering if there is a way to get around this? Below is the R command I am currently using.
myconn1 <- odbcDriverConnect("SERVER=SQL12P4\VSQL1;DRIVER= SQL SERVER")
> myconn1A <-odbcDriverConnect("SERVER=SQL12P4\VSQL1;DRIVER= SQL SERVER")
Error: '\V' is an unrecognized escape in character string starting ""SERVER=SQL12P4\V"
> myconn1B <-odbcDriverConnect("SERVER=SQL12P4\\VSQL1;DRIVER= SQL SERVER")
Warning messages:
1: In odbcDriverConnect("SERVER=SQL12P4\\VSQL1;DRIVER= SQL SERVER") :
[RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
2: In odbcDriverConnect("SERVER=SQL12P4\\VSQL1;DRIVER= SQL SERVER") :
ODBC connection failed
Working through a tutorial to pull database data with:
install.packages('RODBC')
require(RODBC)
myNewDB=odbcConnect("QV Training")
And I get the error:
In odbcDriverConnect("DSN=QV Training")
Data source name not found and no default driver specified
In odbcDriverConnect("DSN=QV Training") : ODBC connection failed
Is 'QV Training' meant to be the name of a database that may no longer be present?
How does R know where to look for the database anyway?
Thank you!
In Windows (unsure of other OSes) you need to go into the ODBC Data Source Administrator, and add the data source. The ODBC Data Source Administrator is accessed via the 'Administrative Tools' section of Control Panel (in Windows 10 at least).
The connection command is then simply
conn <- odbcConnect("QV Training")
library(RODBC)
con <- odbcConnect("Oracle", uid="system", pwd="root", rows_at_time = 500)
sqlQuery(con, "select file_name,sum(bytes)/1024/1024 AS MB from dba_data_files group by file_name")
d <- sqlQuery(con, "select * from dba_data_files")
close(con)