rmysql和data.frame:nas通过强制到整数范围引入

bqujaahr  于 2021-06-19  发布在  Mysql
关注(0)|答案(0)|浏览(195)

我正在从mysql数据库中提取数据。mysql中的数据是float结构,但我在将它们加载到Dataframe时收到以下错误:“nas通过强制引入到integer range”
下面是mysql函数:


## 

## MySQL function

## 

library(RMySQL)
rozDB <- function(q,type) {
  mysql_conn <- dbConnect(
    MySQL(), 
    user="", 
    password="", 
    dbname="", 
    host="")

  if(type == "select") {
    query <- dbSendQuery(mysql_conn, q)
    result <- fetch(query, n = Inf)
    check <- dbHasCompleted(query)
  }

  if(type == "insert") {
    query <- dbSendQuery(mysql_conn, q)
    result <- "Complete"
  }

  dbClearResult(query)
  dbDisconnect(mysql_conn)

  return(result)
}

数据调用:


### 

### Build condition map and number of sessions

### 

conditions <- c()
query1 <- paste0("SELECT notebook_condition conditions, COUNT(notebook_condition) count FROM key_map GROUP BY notebook_condition;")
conditions <- rozDB(query1, "select")

### 

### Get 1 day of 1 condition

### 

selectedCondition <- conditions[3,]

for(i in 1:selectedCondition[1,2]){
  query3 <- paste0("SELECT kx,ky,kz FROM dataread3 WHERE `datetime` BETWEEN (SELECT `start_time` FROM key_map WHERE `cond` = '",selectedCondition[1,1],"' LIMIT ",i,",1) AND (SELECT `end_time` FROM key_map WHERE `cond` = '",selectedCondition[1,1],"' LIMIT ",i,",1);")
  print(query3)
  data <- rozDB(query3,"select")
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题