R数据库提取限制问题
R database extracting limit issue
我是 R 的初学者,我不知道我的标题是否适合这个问题,我在从 R 中的 sql 中提取一些数据时遇到问题,这是代码
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 10000))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 100000))
Error in .local(conn, statement, ...) :
could not run statement: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1e+05' at line 1
Called from: eval(substitute(browser(skipCalls = pos), list(pos = 9 - frame)),
envir = sys.frame(frame))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000000))
Error in .local(conn, statement, ...) :
could not run statement: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1e+06' at line 1
Called from: eval(substitute(browser(skipCalls = pos), list(pos = 9 - frame)),
envir = sys.frame(frame))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000001))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 100000001))
所以我怀疑当限制小于 10000 或最多 4 个零时没有错误但是大约 5 个或更多的零会抛出错误。但是如果限制以 0 以外的数字结尾那么没有错误为什么?
还有select函数
select <- function (query, connection=con) {
return(as.data.frame(dbGetQuery(connection, query)))
}
提前致谢
大数转换为科学计数法,可以运行options(scipen=999)
来防止:
options(scipen=999)
paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000000)
# "SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT 1000000"
要恢复它,运行 options(scipen=0)
:
options(scipen=0)
paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000000)
#"SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT 1e+06"
我是 R 的初学者,我不知道我的标题是否适合这个问题,我在从 R 中的 sql 中提取一些数据时遇到问题,这是代码
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 10000))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 100000))
Error in .local(conn, statement, ...) :
could not run statement: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1e+05' at line 1
Called from: eval(substitute(browser(skipCalls = pos), list(pos = 9 - frame)),
envir = sys.frame(frame))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000000))
Error in .local(conn, statement, ...) :
could not run statement: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1e+06' at line 1
Called from: eval(substitute(browser(skipCalls = pos), list(pos = 9 - frame)),
envir = sys.frame(frame))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000001))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 100000001))
所以我怀疑当限制小于 10000 或最多 4 个零时没有错误但是大约 5 个或更多的零会抛出错误。但是如果限制以 0 以外的数字结尾那么没有错误为什么?
还有select函数
select <- function (query, connection=con) {
return(as.data.frame(dbGetQuery(connection, query)))
}
提前致谢
大数转换为科学计数法,可以运行options(scipen=999)
来防止:
options(scipen=999)
paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000000)
# "SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT 1000000"
要恢复它,运行 options(scipen=0)
:
options(scipen=0)
paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000000)
#"SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT 1e+06"