0

I have a data frame SomeData 1 2015-06-05 2 16:00:00 3 19 4 40 5 985 6 69 7 22

I want to send this data into my postgreSQL table. i have done all the pre-requisite stuff. The data base is connected properly. I can easily send data through dbSendQuery. but this dataset is an object data the command for dbSendQuery(con,"Insert into data values('A','b','C')") Here A , b, c refers to data[1], data[2], data[3] i want the values to be exported but it sends them as data[1] data[2] data[3] rather than 1 2 3

1 Answer 1

3

Package RPostgreSQL has dbWriteTable which enables you to store data in command like this:

dbWriteTable(con, "tableName", df, append=TRUE, row.names=0)

Just keep in mind that column names of your data frame (df) have to be same as fields in the db table.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.