Pyodbc Query w/ SQL Server - sql-server

I’ve been struggling to use pyodbc to execute a query:
• cursor.execute({call my_query})
The query for the Access database requires a connection to a SQL server. My current attempt involves creating two, separate connections: one for the Access database and another for the SQL server.
cnxn1 = pyodbc.connect(‘DRIVER={{Microsoft Access Driver...
cnxn2 = pyodbc.connect(‘DRIVER={SQL Server}...
I’m currently receiving the error
pyodbc.Error: (‘HY000’, ‘[HY000] [Microsoft][ODBC Microsoft Access Driver] ODBC—call failed. (-2001) (SQLExecDirectW)’)
I’d really appreciate some assistance.

Related

Unable to connect to another connection in SSAS Tabular

I have a very weird issue with SSAS Tabular connecting to a SQL Server source database. I've spent almost the entire day on this, and searched online in various ways to find a helpful answer, but none of the suggestions solved this mysterious problem for me.
It used to work fine, but I tried various connection settings (Windows vs SQL authentication, and different impersonation modes), but now I no longer can get it to work (even if I revert back to the previous bim file in source control).
When I process a table from the WORKSPACE database (through SSMS), it works. But when I process a table from the DEPLOYED database (still through SSMS), it does NOT work.
The connection I am using is:
-SQL Server Native Client 11.0
-Windows Authentication
-Impersonation mode of a Windows account (which has the appropriate permissions)
The source database is in a SQL Server database located on a different server (but in the same network).
I have searched everywhere online, but didn't find anything that could help me.
I have tried changing the connection driver (OLE DB Provider for SQL Server), and I have restarted the SSAS Tabular service.
The full error message I get when trying to process a table on the deployed database is:
Failed to save modifications to the server. Error returned: 'OLE DB or ODBC error: Login timeout expired; HYT00; A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.; 08001; Named Pipes Provider: Could not open a connection to SQL Server [5]. ; 08001.
A connection could not be made to the data source with the Name of 'DataWarehouse'.
'.
In fact, after I tried a second time to restart the SSAS Tabular service, the error message I get after attempting to process a table is slightly different:
Failed to save modifications to the server. Error returned: 'OLE DB or ODBC error: A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.; 08001; SSL Provider: The requested security package does not exist
; 08001; Client unable to establish connection; 08001; Encryption not supported on the client.; 08001.
A connection could not be made to the data source with the Name of 'DataWarehouse'.
'.
According to your description, it seems to be related to connection problem. You need to check whether corresponding SQL server service and SSAS Service is running(check server which contains "DataWarehouse" is running and can be connected). You could go to "SQL Server Configuration Manager " to restart them.
In addition, you also need to make sure your current windows credential can access this database(if you use window credential). And check whether this server enable remote connect.
Zoe

How to connect MicroStrategy 10 to SQL Server

I have a problem on connecting microstrategy to a local database:
I'm unable to resolve this error, though I have tried everything in ODBC origins, and tried various drivers.
The server name is correct (SQLExpress2017)
If anyone knows how to resolve this issue, please help.
How to connect Micro Strategy 10 to SQL Server
We cannot connect the SQL SERVER 2017 through local by making the sql server dynamic access by allowing TCP/IP using(sql configuration manager)
NOTE
1)Within your network your system be accessible making dynamic sql server
After create odbc in Microstrategy server.in creating ODBC password should be your sql server username and password and create database instance in microstrategy.using datawarehouse catalog fetch the table based upon the instance you created

How do I resolve encryption error connecting to SQL Server from Oracle SQL Developer

My objective is to use the migration tool in SQL Developer to migrate 2 SQL Server databases to Oracle. I am attempting to connect to a SQL Server database at a remote location using Oracle SQL Developer 4.0.
I have installed jtds.1.3.0.jar per instructions, and get the SQL Server and Sybase tabs in the connection properties window.
I have entered the user, pw, hostname, port, and database name. When I try to Retrieve Database, or connect, I get the error message:
Status : Failure -Test failed: I/O Error: DB server closed connection.
The SQL Server DBA tells me her error logs contain the following error message:
Encryption is required to connect to this server but the client library does not support encryption; the connection has been closed. Please upgrade your client library. [CLIENT: (my computer's IP address)] Error: 17835, Severity: 20, State: 1.
When I look at SQL Server documentation about this error message, it talks about certificates and SQL Server Connection Manager. Some relevant information to show that I've covered the basics:
Using the same connection parameters, I am able to connect to the SQL Server database using Toad for SQL Server.
Using the same connection parameters, a DBA set up an Oracle Transparent Gateway, and I can connect to the SQL Server database using the gateway and a database link. (As far as I know, neither of these methods required a certificate to connect.)
Both of these use ODBC; SQL Developer uses jdbc with TCP/IP.
The DBA assures me TCP/IP connection is turned on for the SQL Server databases.
I have gone into the XML file where SQL Developer stores the connection string. It has the form jdbc:jtds:sqlserver://sql-xxx-xxx.mw.nos.xxx.com:1433/my_db, which looks correct. I have tweaked it by adding the instance name, but no difference. The database has a default instance name, anyway, so it shouldn't be necessary.
A co-worker has been able to connect to a local SQL Server database on the same machine where SQL Developer was running (both on his laptop).
As a workaround, I am also pursuing the possibility of installing SQL Server on a local workstation, and copying the databases there for processing, but I don't know if I can get approval. If you know another tool for migrating from SQL Server to Oracle, please also let me know.
Thanks in advance.

Pulling data from Azure SQL database into an Excel through a parameterised stored procedure

I have data in an Azure SQL database, which I would like to pull into an Excel sheet through the use of stored procedure(s) which require parameters.
However, I'm struggling to do this, as I cannot get it to work how it works with a local SQL server. Ordinarily this is done through Microsoft Query, defining the connection to the database, and entering { CALL sproc (?) } and then using the Connections command to map a cell to the parameter.
I cannot set up a connection to the database in MS Query. When I enter the xxx.database.windows.net as the server, my username / password, and then try to switch to database I need to use I get the message below
Filling listbox failed:
SQLState: '37000'
SQL Server Error: 40511
[Microsoft][ODBC SQL Server Driver][SQL Server]Built-in function 'has_dbaccess' is not supported in this version of SQL Server.
Can anyone offer any assistance please?
Create a text file with the .DSN extension then add content like the following into it...
[ODBC]
DRIVER=SQL Server
SERVER=xxxxxxxx.database.windows.net,1234
APP=Microsoft Office 2010
WSID=NA
DATABASE=DB12345
[Microsoft Office]
UID=myUsername
PWD=myPassword
You can then just use this connection from Microsoft Query without dealing with the dialogs that are giving you grief.
I just figured this out with a combination of Youtube videos and dumb luck lol. You have to create an OBDC connection with Microsoft ODBC Driver 13.1 for SQL Server (or higher.) Make sure you connect and define the correct database in the ODBC object while entering in your Azure SQL connection info. Once that's done from within excel you can use MS Query to select that ODBC object and pull the data as you normally would.

How to create a new ODBC connection to one remote SQL Server

I'm trying to run an application that I've developped recently. This one uses an ODBC connection to browse a defined database.
I'm trying to execute this app from a remote computer. Using VMWare, I've created a new Windows 7 environment and connected on. After that I've tried to create a new System DSN, but, when I set the logins that I'm using to connect on my local SQL Server 2008 I get
Connection failed: SQLState: '28000' SQL Server Error: 18452
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed. The login
is from an untrusted domain and cannot be used with Windows
authentication.
How may I to deal with this, please?
Thanks a lot!
You will have to use SQL Server authentication to connect or add the local machine to the same domain where the server is.
http://msdn.microsoft.com/en-us/library/ms144284.aspx

Resources