2017-09-25 4 views
0

dplyrを使用してテーブルにデータを追加すると、https://stackoverflow.com/a/26784801/1653571が表示されますが、ドキュメントにはdb_insert_table()は推奨されていません。dplyrを使用してsqlite3にデータを追加できませんdb_write_table()

?db_insert_into() 

... 
db_create_table() and db_insert_into() have been deprecated in favour of db_write_table(). 
... 

私の代わりに非は非推奨db_write_table()を使用しようとしましたが、それはとしてappend=オプションを使用せずに、両方の失敗:

require(dplyr) 

my_db <- src_sqlite("my_db.sqlite3", create = TRUE)     # create src 
copy_to(my_db, iris, "my_table", temporary = FALSE)     # create table 
newdf = iris               # create new data 

db_write_table(con = my_db$con, table = "my_table", values = newdf) # insert into 
# Error: Table `my_table` exists in database, and both overwrite and append are FALSE 

db_write_table(con = my_db$con, table = "my_table", values = newdf,append=True) # insert into 
# Error: Table `my_table` exists in database, and both overwrite and append are FALSE 

1はdb_write_table()にデータを追加することができるでしょうか?

も参照してくださいhttps://github.com/tidyverse/dplyr/issues/3120

答えて

0

いいえ、あなたは(db_write_tableを使うべきではない)の代わりに、db_insert_table()、それはバックエンド間で一般化することができないため。

そして、関連するDBI :::バージョンではなく、tidyverseバージョンを使用するべきではありません。これは、tidyverseヘルパー関数が内部で使用され、ユーザーが使用するのに十分なほど堅牢ではないためです。 https://github.com/tidyverse/dplyr/issues/3120#issuecomment-339034612のディスカッションを参照してください:

実際、私はこれらの機能をまったく使用するべきではないと思います。そのSOの投稿にもかかわらず、これらはユーザ向きの機能ではありません。 DBI関数を直接呼び出す必要があります。
- Hadley Wickham、パッケージ作成者。

関連する問題