Tsung Erlang 函数 (dynvars) - 转义引号

发布于 2024-08-10 11:57:11 字数 1281 浏览 3 评论 0原文

Tsung 和 Erlan 是新手,遇到了一个我无法找到答案的问题。我在 Tsung dynvars Erlang 函数中使用 erlang-mysql-driver ,我似乎遇到了转义引号的问题。

我想做这样的事情:

      <setdynvars sourcetype="eval"
              code='fun({Pid,DynVars})->
                  mysql:start_link(p1, "localhost", "user", "pass", "db"), 
                  Result = mysql:fetch(p1, "SELECT * FROM consumers WHERE first_name=\'Doonley\'") end.'>
      <var name="myres" />
    </setdynvars>

但我收到空格错误:

Douglas-Sparlings-MacBook-Pro:.tsung dsparling$ tsung start
Starting Tsung
"Log directory is: /Users/dsparling/.tsung/log/20091110-16:35"
3284- fatal: {whitespace_required_between_attributes}
["Config Error, aborting ! ",{fatal,{{whitespace_required_between_attributes},{file,"/Users/dsparling/.tsung/tsung.xml"},{line,72},{col,221}}}]

我实际上需要使用变量进行选择,但我不确定语法。我正在寻找类似以下内容的内容:

      <setdynvars sourcetype="eval"
              code='fun({Pid,DynVars})->
                  Val='Doonley",
                  mysql:start_link(p1, "localhost", "user", "pass", "db"), 
                  Result = mysql:fetch(p1, "SELECT * FROM consumers WHERE first_name=?", Val) end.'>
      <var name="myres" />
    </setdynvars>

New to Tsung and Erlan and have run into an issue I haven't been able to find answer to. I'm using erlang-mysql-driver in a Tsung dynvars Erlang function and I seem to be having a problem with escaped quotes.

I'd like to do something like this:

      <setdynvars sourcetype="eval"
              code='fun({Pid,DynVars})->
                  mysql:start_link(p1, "localhost", "user", "pass", "db"), 
                  Result = mysql:fetch(p1, "SELECT * FROM consumers WHERE first_name=\'Doonley\'") end.'>
      <var name="myres" />
    </setdynvars>

but I get a whitespace error:

Douglas-Sparlings-MacBook-Pro:.tsung dsparling$ tsung start
Starting Tsung
"Log directory is: /Users/dsparling/.tsung/log/20091110-16:35"
3284- fatal: {whitespace_required_between_attributes}
["Config Error, aborting ! ",{fatal,{{whitespace_required_between_attributes},{file,"/Users/dsparling/.tsung/tsung.xml"},{line,72},{col,221}}}]

I actually need to use a variable for the select, but I'm not sure of the syntax. Something like the following is what I'm looking for:

      <setdynvars sourcetype="eval"
              code='fun({Pid,DynVars})->
                  Val='Doonley",
                  mysql:start_link(p1, "localhost", "user", "pass", "db"), 
                  Result = mysql:fetch(p1, "SELECT * FROM consumers WHERE first_name=?", Val) end.'>
      <var name="myres" />
    </setdynvars>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尹雨沫 2024-08-17 11:57:11

尝试将单引号转义为 '。例如:

  <setdynvars sourcetype="eval"
          code='fun({Pid,DynVars})->
              mysql:start_link(p1, "localhost", "user", "pass", "db"), 
              Result = mysql:fetch(p1, "SELECT * FROM consumers WHERE first_name='Doonley'") end.'>
  <var name="myres" />
</setdynvars>

Try escaping the single quotes as '. E.g.:

  <setdynvars sourcetype="eval"
          code='fun({Pid,DynVars})->
              mysql:start_link(p1, "localhost", "user", "pass", "db"), 
              Result = mysql:fetch(p1, "SELECT * FROM consumers WHERE first_name='Doonley'") end.'>
  <var name="myres" />
</setdynvars>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文