使用 Windows 身份验证连接到 sqlalchemy
Connecting to sqlalchemy Using Windows Authentication
我正在查看 sqlalchemy engine interface dialect 列出的文档,但我看不到它在哪里说明如何执行此操作。
我知道我需要使用 trusted_connection = 'yes'
,但我想知道它在哪里说这是我们需要做的。
有人能给我指出正确的方向吗?
我想通了。
要做什么:
1) 使用DBAPI连接数据库,我的例子是pyodbc
.
2) 您将传递的连接字符串将基于正在使用的驱动程序,在我的例子中,ODBC Driver 11 for SQL Server
.
3) 在用于我的驱动程序的语法中,它明确表示使用 trusted_connection='yes'
进行 windows 身份验证。
4) 您需要传递给 create_engine
的值与您要发送给您正在使用的驱动程序的值相同。
详情:
1) 我在做什么:
我正在使用 pyodbc
访问 SQL 服务器。然后我使用 sqlalchemy
来处理数据库。
2) Trusted_connection = 'yes'
在 the documentation for SQLAlchemy 上找不到,因为它是连接字符串的一部分,而不是 create_engine
的语法。
3) Documentation for pyodbc and Connection Strings. Pyodbc does not look at the connection string. The connection string is passed to the databse driver unmodified and is driver-specific. Documentation for Connecting to databases
4) Reference for all connection strings 可以具体告诉您连接字符串对于您尝试连接的每个数据库需要是什么样子。
5) 不是我最初问题的一部分,但也对此感到好奇:只有在网络外部连接时才需要端口号 SQL 服务器已开启。 When is Port Number Required
6) 在create engine documentation中它说URL是第一个位置参数,但是当你查看参数时,它并没有指定这个。我希望有人能证明我错了,但我确信这是真的。
我正在查看 sqlalchemy engine interface dialect 列出的文档,但我看不到它在哪里说明如何执行此操作。
我知道我需要使用 trusted_connection = 'yes'
,但我想知道它在哪里说这是我们需要做的。
有人能给我指出正确的方向吗?
我想通了。
要做什么:
1) 使用DBAPI连接数据库,我的例子是pyodbc
.
2) 您将传递的连接字符串将基于正在使用的驱动程序,在我的例子中,ODBC Driver 11 for SQL Server
.
3) 在用于我的驱动程序的语法中,它明确表示使用 trusted_connection='yes'
进行 windows 身份验证。
4) 您需要传递给 create_engine
的值与您要发送给您正在使用的驱动程序的值相同。
详情:
1) 我在做什么:
我正在使用 pyodbc
访问 SQL 服务器。然后我使用 sqlalchemy
来处理数据库。
2) Trusted_connection = 'yes'
在 the documentation for SQLAlchemy 上找不到,因为它是连接字符串的一部分,而不是 create_engine
的语法。
3) Documentation for pyodbc and Connection Strings. Pyodbc does not look at the connection string. The connection string is passed to the databse driver unmodified and is driver-specific. Documentation for Connecting to databases
4) Reference for all connection strings 可以具体告诉您连接字符串对于您尝试连接的每个数据库需要是什么样子。
5) 不是我最初问题的一部分,但也对此感到好奇:只有在网络外部连接时才需要端口号 SQL 服务器已开启。 When is Port Number Required
6) 在create engine documentation中它说URL是第一个位置参数,但是当你查看参数时,它并没有指定这个。我希望有人能证明我错了,但我确信这是真的。