tiny_tds 在第二次执行时失败
今天,tiny_tds 突然不接受多个 execute
并返回:
C:\>ruby test_use.rb
one
two
C:/test_use.rb:15:in `execute': Attempt to initiate a new Adaptive Server operation with results pending (TinyTds::Error)
from C:/test_use.rb:15
代码很简单,只有三个 USE
:
require 'rubygems'
require 'yaml'
require 'fastercsv'
require 'tiny_tds'
require 'iconv'
CONFIG = YAML.load_file("config.yml")
client = TinyTds::Client.new(:username => CONFIG["db"]["username"], :password => CONFIG["db"]["password"],
:host => CONFIG["db"]["server"], :database => CONFIG["db"]["database"])
puts "one"
client.execute("USE DATAFEED")
puts "two"
client.execute("USE DATAFEED")
puts "three"
client.execute("USE DATAFEED")
有什么线索吗?我已经尝试重新启动 Windows 机器。
Today, tiny_tds suddenly does not accept more than one execute
and returns:
C:\>ruby test_use.rb
one
two
C:/test_use.rb:15:in `execute': Attempt to initiate a new Adaptive Server operation with results pending (TinyTds::Error)
from C:/test_use.rb:15
The code is simply as three USE
s:
require 'rubygems'
require 'yaml'
require 'fastercsv'
require 'tiny_tds'
require 'iconv'
CONFIG = YAML.load_file("config.yml")
client = TinyTds::Client.new(:username => CONFIG["db"]["username"], :password => CONFIG["db"]["password"],
:host => CONFIG["db"]["server"], :database => CONFIG["db"]["database"])
puts "one"
client.execute("USE DATAFEED")
puts "two"
client.execute("USE DATAFEED")
puts "three"
client.execute("USE DATAFEED")
Any clue what is the problem? I tried rebooting the Windows machine already.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是我如何做的一个例子。
Here is an example of how I do it.
您必须使用
do
终止执行:Client.execute("...").do
You have to terminate the execute with a
do
:Client.execute("...").do
根据 GitHub 上的 TinyTds 文档:
重要的是,您要么从查询,最有可能使用 #each 方法,或者在要求客户端执行另一个 SQL 批处理之前取消结果。如果不这样做将会产生错误。
要取消查询,请使用
cancel
方法:According to the documentation for TinyTds on GitHub:
It is important that you either return the data from the query, most likely with the #each method, or that you cancel the results before asking the client to execute another SQL batch. Failing to do so will yield an error.
To cancel the query, use the
cancel
method:您必须调用
do
或cancel
。如果您正在执行诸如获取部分结果之类的操作,并且您对执行do
方法不感兴趣,则可以调用cancel
来中止查询。You have to call
do
ORcancel
. If you are doing something like getting a partial results, and you are not interested in execute thedo
method you can callcancel
to abort the query.