首页 \ 问答 \ 允许参数化SQL查询的哪些部分?(What parts of a SQL query are allowed to be parameterized?)

允许参数化SQL查询的哪些部分?(What parts of a SQL query are allowed to be parameterized?)

例如,通常允许这样做:

sql.execute("select * from some_table where some_column=@parameter", parameter=5);

但不是这个:

sql.execute("select * from @which_table where some_column=5", which_table="some_table");

没有测试所有可能的组合......是这样的:

sql.execute("select @which_column from some_table", which_column="some_column");

或这个:

sql.execute("select some_column*@multiplier from some_table", multipler=5);

要么....

确定查询的某些部分是否可参数化的一般规则是什么?为什么?

(我意识到对于不同语言的不同数据库引擎和适配器,这可能有不同的答案,但我注意到有一般趋势)


For instance, this is generally allowed:

sql.execute("select * from some_table where some_column=@parameter", parameter=5);

But not this:

sql.execute("select * from @which_table where some_column=5", which_table="some_table");

Having not tested all possible combinations.... Is this:

sql.execute("select @which_column from some_table", which_column="some_column");

Or this:

sql.execute("select some_column*@multiplier from some_table", multipler=5);

Or....

What is the general rule for determining whether some part of a query is parameterizable, and why?

(I realize that this may have different answers with respect to different DB engines and adapters for different languages, but I've noticed that there are general trends)


原文:https://stackoverflow.com/questions/44315421
更新时间:2023-11-11 10:11

最满意答案

原版scribe-js是根据麻省理工学院的许可证发布的,这意味着你基本上可以用包装做你想做的事情,甚至修改和销售它,但你必须保留版权和许可证本身的标志。


Original scribe-js is published under MIT license, what means you can basically do what you want with the package, even modify and sell it, but you must keep the indication of copyright and the license itself.

相关问答

更多
  • 对不起,没办法那样做。 您可以做的是在部署时添加额外的行。 $ npm install my_module $ NODE_ENV=production npm install 当你完成模块开发(假设你不想再链接它,因为它已经准备好生产)时,你只需删除那条额外的行并将它添加到你的依赖项中。 另一个想法是在部署脚本中修改package.json文件以进行生产。 这将确保仅为生产安装模块。 Sorry, there is no way to do that. What you could do is add ...
  • npm install不只是将代码从Internet复制到node_modules。 安装可能还会编译平台的代码。 因此,如果您要从同一平台进行复制,那么应该没问题。 尽管如此,根据环境,某些模块可能无法工作。 npm install doesn't just copy code from the Internet to node_modules. The installation might also compile code for the platform. So if you are copying ...
  • 一切似乎都工作正常。 唯一需要记住的是npm是node.js的工具,这意味着您可以将其用于与节点本身相关的某些需求(就像Python中的pip或RoR中的bundler一样)。 所以你可以做的是: 安装express.js。 这是在node.js中工作的第一件事情。 跑: npm install express-generator -g 这将在系统上而不是在应用程序上安装express(这意味着你的问题出现,因为你试图安装节点模块而不是在应用程序目录中)。 然后创建一个你计划使用你的应用程序的目录并转到那 ...
  • 我前一段时间遇到过类似的问题。 尝试导航到C:\Users\%UserName%名为.npmrc的文件,然后将其删除。 I had a similar problem a while ago. Try navigating to the file named .npmrc, in C:\Users\%UserName%, and deleting it.
  • 原版scribe-js是根据麻省理工学院的许可证发布的,这意味着你基本上可以用包装做你想做的事情,甚至修改和销售它,但你必须保留版权和许可证本身的标志。 Original scribe-js is published under MIT license, what means you can basically do what you want with the package, even modify and sell it, but you must keep the indication of cop ...
  • 首先尝试清理npm缓存: rm -rf ~/.npm npm cache clear 下一步,您可以尝试重建现有的包: npm rebuild 也有人说,Node版本5.1可以解决这个问题: 放入节点5后,npm ERR! 代码EINVALIDTYPE? Try to clean your npm cache at first: rm -rf ~/.npm npm cache clear Next step you could try to rebuild your existing packages: n ...
  • 注册表URL指向https,试试这个 npm config set registry="http://registry.npmjs.org/" 然后尝试安装模块。 您可能是阻止安全(https)连接的代理。 The registry URL is pointing to https, try this npm config set registry="http://registry.npmjs.org/" and then try installing the module. You are behin ...
  • 看一下docs http://nodejs.org/docs/latest/api/modules.html : 在节点中,文件和模块是一一对应的。 另一方面,package是一个包含特殊package.json文件的文件夹。 该文件告诉解释器如何在require(folder);时加载模块require(folder); 。 换句话说,package是模块的集合。 Have a look at docs http://nodejs.org/docs/latest/api/modules.html : In ...
  • 未使用相对路径引用的节点模块的NPM解析是首先检查当前目录,然后向上遍历每个目录,查找node_modules文件夹。 所以在你的情况下,如果你想要相同的软件包/模块的相同版本,只需在main中安装: 最后,您可以全局安装所需的软件包/模块 - 但是,这通常仅建议您从命令行所需的软件包(例如gulp,webpack等)。 在你的情况下,对于特定于应用程序的模块,最好将它们保存在本地安装在node_modules文件夹下。 关于安装npm软件包的一些有用的NPM文档: 请参阅“从node_modules文件夹 ...
  • 嗯,正确的做法是向维护者提交补丁,以便可以在上游(长期)修复。 同时,只需保留修改后的文件,安装主包后,重命名原始文件( mv file.js file.js.ORIG ),然后在副本中复制符号链接( ln -s ../../../patches/jsdom/level2/languages/file.js file.js )。 这是一个快速和肮脏的选择。 另一种选择是使用修改后的源代码和点NPM来构建新的npm tarball。 npm install命令可以将本地文件系统路径导入.tar.gz存档。 那 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。