如何在 Sequel 中放置原始 SQL 查询 [英] How to put a raw SQL query in Sequel

查看:46
本文介绍了如何在 Sequel 中放置原始 SQL 查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 SQL 代码转换为 Seqel 以从我的脚本中运行它.我该如何转换:

I am trying to convert SQL code to Seqel to run it from my script. How do I convert this:

select code, count(1) as total 
from school_districts 
group by code order by total desc;

进入续集?或者,有没有办法将原始 SQL 传递给 Sequel?此外,school_districts 将被插入#{table_name}.

into Sequel? Or, is there a way to pass raw SQL to Sequel? Also the school_districts will be interpolated #{table_name}.

推荐答案

您可以通过以下几种方式:

You can do it a couple ways:

  1. 使用[]:

DB["your sql string"]

  • 使用fetch:

    DB.fetch("your sql string")
    

  • 这篇关于如何在 Sequel 中放置原始 SQL 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆