- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我一直无法找到记录的方法来为实际有效的初始连接设置超时。我不是在询问“查询超时”,而是在数据库服务器完全关闭或无法访问且根本没有响应的情况下初始连接尝试超时。默认情况下,此类连接似乎会在 255 秒后超时 - 是否可以设置更短的超时时间?
编辑:为了清楚起见,我应该在这里重申堆栈:
最佳答案
https://stackoverflow.com/a/12946908/1552953
这个答案是指能够在连接上设置超时:
Timeout
An optional integer query timeout, in seconds. Use zero, the default, to disable.
The timeout is applied to all cursors created by the connection, so it cannot be changed for a given connection.
If a query timeout occurs, the database should raise an OperationalError with SQLSTATE HYT00 or HYT01.
Note: This attribute only affects queries. To set the timeout for the actual connection process, use the timeout keyword of the pyodbc.connect function.
result = None
with pyodbc.connect('DRIVER={SQL Server};SERVER=mydb;DATABASE=solarwinds;Trusted_Connection=True', timeout=1) as cnxn:
cursor = cnxn.cursor()
result = cursor.execute(query).fetchall()
所以使用上面的代码并没有在1秒内超时,或者至少在1秒内没有返回结果。但它返回结果的速度确实比没有设置超时快得多。
关于python - 如何为 SQL Server/Linux 堆栈的 python/pyodbc/unixODBC/MS ODBC 驱动程序 11 设置数据库连接超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18774102/
这个问题已经有答案了: what is the difference between OLE DB and ODBC data sources? (11 个回答) 已关闭10 年前。 OLEDB 和
我正在制作安装脚本并且我正在使用 ODBC,我如何自动将节点添加到 ODBC 数据源。 使用 Visual Studio 安装项目构建安装程序,但我能够为其运行任何脚本。 谢谢。 最佳答案 1) OD
所以我正在将一个旧的 filemaker 数据库传输到 MySQL,一些重复的字段给我带来了一些问题。我读过 ODBC 标准支持这些字段,只有当它们的类型是“文本”并且每个重复都与某个定界符( see
一个月前,我向一个哥们展示了如何使用 .NET 来查询 MySQL。它工作得很好,但他不明白为什么我们需要一个 MySQL 与 ODBC 结合的“驱动程序”。他认为 ODBC 就足够了。 当他问我为什
为什么 ODBC 很慢?底层架构是什么?有人可以对此多加关注> 最佳答案 一般来说(我的意思是 GENERAL)ODBC 驱动程序在混合中添加了另一层。它必须接受您的查询并将其转换为本地查询语言(本地
问题:我正在使用 AsteriskNow,它在 VirtualBox 中运行 asterisk 2.0 服务器。我想使用 ODBC 模块将 Asterisk 与 MySQL 数据库连接起来。但它失败了
我有一个名为“myodbc”的用户定义的 ODBC 连接,其中保存了用户名和密码。这是管理员为我创建的,因此我无法访问凭据。 如何在不传递凭据的情况下与 SAS 建立连接。我认为以下工作会,但我收到无
我最近发现 libname 语句对于访问驻留在 odbc 中的表非常方便。但我不知道如何访问那些具有两级名称的表。下面是一个例子。 我使用的旧代码(此代码有效): proc sql; conn
我们通常使用 MS Visual Foxpro v9.0 SP1、语言、表格和报告。但是,有时我们使用 ODBC 驱动程序连接到表。 ODBC 驱动程序是为 Foxpro v6 编写的,不支持某些嵌套
我第一次尝试在使用 PostgreSQL 9 的 Windows XP Pro 上打开一个程序。我收到一条错误消息: A problem was encountered while trying to
我有一个 spark 集群设置,并在我的数据集上尝试了 native scala 和 spark sql,该设置似乎在大多数情况下都有效。我有以下问题 从 ODBC/外部连接到集群,我应该期待什么?
我正在尝试为 Hive 设置 ODBC 连接。我按照以下步骤操作,但没有成功。 用户 DSN-->添加--> Hortonworks Hive ODBC 驱动程序--> 我提供了以下详细信息 主机:主
我找不到任何文档或示例。到目前为止,我可以成功连接,但是我不知道选择和返回数据的语法。 :odbc.start() {:ok, conn} = :odbc.connect('DSN=mydsn;UID
我正在阅读一篇有关数据透视缓存的 MS Excel 帮助文章,并想知道 OLE DB 和 ODBC 源 的含义 ...You should use the CommandText property i
从应用程序调用 SQLColAttribute 时出现 SQL_INVALID_HANDLE 错误(尝试与自行开发的 odbc 驱动程序通信)我不知道为什么句柄被声明为无效句柄,因为它是一个简单的结构
我有一个简单的 SQL,需要通过 ODBC 调用 RedShift。SQL是这样的 SELECT id as Tag From SomeView 这根本不起作用。它给了我错误 DataSource.E
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
从应用程序调用 SQLColAttribute 时出现 SQL_INVALID_HANDLE 错误(尝试与自行开发的 odbc 驱动程序通信)我不知道为什么句柄被声明为无效句柄,因为它是一个简单的结构
我有一个简单的 SQL,需要通过 ODBC 调用 RedShift。SQL是这样的 SELECT id as Tag From SomeView 这根本不起作用。它给了我错误 DataSource.E
我正在尝试使用 BIML 生成自动暂存区域。源数据库为Progress,通过ODBC连接。 我正在使用以下演练: https://www.cathrinewilhelmsen.net/2015/07/
我是一名优秀的程序员,十分优秀!