1

I've been reading into DuckDB recently and most of the examples involve having some sort of data already in an R session, then pushing that data into DuckDB.

Here is a basic example of that using the iris dataset;

library("DBI")
con = dbConnect(duckdb::duckdb(), ":memory:")
dbWriteTable(con, "iris_table", iris)
dbGetQuery(con, 'SELECT "Species", MIN("Sepal.Width") FROM iris_table GROUP BY "Species"')

Let's say I have data in a sql server table and want to directly write that data into a duck db.

Is there a way to do this?

if I had a sql query

' SELECT * FROM iris_table "

and wanted to read that directly into DuckDB, how would that work? I haven't seen any examples of this online

  1. How would that work?
  2. Would this even be a smart or desirable approach?

2 Answers2

1

I would try to export from SQL Server to Parquet files and then directly query those or import in DuckDB.

Hannes Mühleisen
  • 2,542
  • 11
  • 13
1

I'd try this approach

  • Within R, import data from SQL Server into an R dataframe
  • Within R, export the data from the R dataframe to DuckDB
TC1
  • 21
  • 4