sql - dbGetQuery 在命令中不将用户识别为数据库,而是将其识别为一些系统变量
问题描述
我正在尝试使用 PostgreSQL 连接到 R 中的数据库。但是,我对数据库用户的引号有疑问 - sql 将用户视为某种系统变量。因此在标准 sql 接口中我会使用
select count(*), email, name
from http_request_log hrl
inner join user_access_token uat on hrl.access_token_id = uat.id and uat.impersonated_by_id is null
inner join "user" u on uat.user_id = u.id
inner join customer c on u.customer_id = c.id
where hrl.created_time >= '2020-05-01'
group by u.email, c.name
order by count(*) desc
但是在 R 中,使用 dbGetQuery,引号存在问题 - 我不能使用“用户”,如果我更改为 ' 它不起作用 - 它仅在整个命令开始并以 ' 而不是“结束时才有效 - 但是然后where 子句不起作用,因为它无法识别日期
uzivatele <- dbGetQuery(con,
"select count(*), email, name
from http_request_log hrl
inner join user_access_token uat on hrl.access_token_id = uat.id and uat.impersonated_by_id is null
inner join 'user' u on uat.user_id = u.id
inner join customer c on u.customer_id = c.id
where hrl.created_time >= '2020-05-01'
group by u.email, c.name
order by count(*) desc")
解决方案
推荐阅读
- android - Android:“应用信息”内的应用图标不同
- list - 具有通用 Comparable 作为参数的 Dart List.sortedBy 函数不会操纵列表
- angular - 无法在网络选项卡中看到延迟加载的模块
- selenium - 无效参数 - org.openqa.selenium.InvalidArgumentException - Selenium JAVA
- excel - 为数字值添加文本框自动过滤器
- php - 当安装包而不是单个学说依赖项时,如何更新 orm-pack 的单个包?
- python - Python终端打开后出现错误
- python - 如何在 Django 中集成 Coinbase
- pandas - 熊猫数据框分组时间序列数据
- cuda - 在 Cuda Fortran 中使用其他文件中的托管模块变量的问题