SQL Alchemy with SQL Server
NickName:Chicken Sandwich No Pickles Ask DateTime:2020-05-26T08:50:37

SQL Alchemy with SQL Server

I wasn't sure what to title my post, if you have a better idea, feel free to edit the title.

I have not used SQL Alchemy before and the documentation that I have looked at located in the following places, is not helpful:

Here is the code I am using:

import sqlalchemy as sal
from sqlalchemy import create_engine
#Here are the parameters I am using:

 - server = 'Q-20/fake_example'
 - database = 'AdventureWorks2017'
 - driver = 'ODBC Driver 17 for SQL Server' 
 - trusted_connection='yes'

DATABASE_CONNECTION = 'mssql+pyodbc://@server = ' + server + '/database = ' + database + '?trusted_connection = ' + trusted_connection + '&driver=' + driver

engine = sal.create_engine(DATABASE_CONNECTION)

All of that seems to work fine without any problems; however, when I add this line:

connection=engine.connect()

I get the following error message:

sqlalchemy.exc.OperationalError: (pyodbc.OperationalError) ('08001', '[08001] [Microsoft][ODBC Driver 17 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [53]. (53) (SQLDriverConnect); [08001] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0); [08001] [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute (0); [08001] [Microsoft][ODBC Driver 17 for SQL Server]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. (53)')

I am not sure what is wrong with what I am doing, does anyone have any suggestions?

What I have tried so far:

  1. I have confirmed that SQL Server is configured to allow remote connections. I did this check by following the instructions here
  2. Removing the "@" sign before the server, but this just generated the same error message.

Copyright Notice:Content Author:「Chicken Sandwich No Pickles」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/62012968/sql-alchemy-with-sql-server

More about “SQL Alchemy with SQL Server” related questions

SQL Alchemy with SQL Server

I wasn't sure what to title my post, if you have a better idea, feel free to edit the title. I have not used SQL Alchemy before and the documentation that I have looked at located in the following

Show Detail

configure sql server in Airflow with sql_alchemy_conn

I am trying to configure the SQL server in Airflow with sql_alchemy_conn. Airflow is running in the Linux server and DB is in windows. I have just started exploring Airflow, can anyone help me wit...

Show Detail

SQL Server slow/slower than Python/SQL Alchemy

Our team has been experiencing slow returns for our SQL queries in Microsoft SQL Server Management Studio. This just started recently, the slowness fluctuates seemingly randomly (doesn't correlate to

Show Detail

Get server name (SQL Server Host) through SQL Alchemy session or engine

Where is the server name found in the SQL Alchemy session or engine? I prefer not parsing the query property. e = connManager.get_engine() e.engine.url mssql+pyodbc:///?odbc_connect=DRIVER={SQL

Show Detail

Dataframe to sql without Sql Alchemy engine

i have a dataframe id value name 1 100 sam 2 766 abc 3 234 qqq 4 435 ppp 5 345 mmm i want to save this table into sql server database...

Show Detail

How do I create a Graph Node Table in SQL Server using SQL Alchemy?

I'm trying to create a Graph Table in SQL Server using SQLAlchemy. SQL would be as follows: CREATE TABLE [audit].[tableMetaData]( [_tableMetaDataId] INT PRIMARY KEY IDENTITY(1,1), [table]

Show Detail

Programmatically generate sql alchemy?

I have an input form with 3 input fields. The user can choose to fill between 1 and 3 of the input fields. I am generating a SQL alchemy query based on their input. If the user has not filled out a...

Show Detail

SQL Alchemy Check Connection

I created the below method to connect to SQL Server using SQL Alchemy and Pyodbc. def getDBEngine(server, database): Params = urllib.quote_plus("DRIVER={SQL Server};SERVER="+server+";DATABAS...

Show Detail

Connection pooling for sql alchemy and postgres

I have a situation where i have lots of individual database connections ( close to 1000) that are per customer database. From my sql alchemy, i open and close connections to keep the max connection...

Show Detail

Sql alchemy quote database bind parameter on postgres

I am new to sql alchemy. I have a postgres local server, and I want to use sql alchemy to create a database. I have the following code: connection = engine.connect() connection.execute( text("

Show Detail