r - sqlSave pads numeric/integer with space -


i have data trying upload table in database. example:

df <- data.frame(name = c("fred", "george", "david"), data = c(10, 100, 1000)) 

when using rodbc::sqlsave function (with fast = false insert 1 row @ time) however, padding numeric or integer values spaces. in database, entries under data column " 10", " 100", "1000". example, if upload above dataframe , query data using following

tmp = rodbc::sqlquery(ch, query = "select * my_tbl") 

then output this:

> str(tmp) 'data.frame':   3 obs. of  2 variables: $ name : chr "fred" "george" "david" $ data : chr "  10" " 100" "1000" 

the database data type data column of type varchar(10) data have leading letter. in case working however, there numbers involved.

my question why sqlsave function padding numeric data , there can stop doing so?

note: know sqlsave function causing issue because when use verbose = true, can see output of insert statements , indeed have padded data. also, made data purposes of example.

from of sqlsave:

if fast = false data sent character strings. if fast = true, integer , double vectors sent types sql_c_slong , sql_c_double respectively.

so try without fast=false option. try typeinfo option.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -