DuckDB Plugin for Xojo

EinhugurDuckDB.Appender Class (console safe)

A class for large bulk appends.

The makers of DuckDB recommend using the appender class for large amount of inserts.

Object
   Appender

class EinhugurDuckDB.Appender

Constructors

AppenderPrivate constructor.

Methods

AppendBlobAdds BLOB field to the row.
AppendBooleanAdds Boolean field to the row.
AppendCurrencyAdds Currency field to the row.
AppendDateAdds Date field to the row.
AppendDoubleAdds Double field to the row.
AppendInt16Adds Int16 field to the row.
AppendInt32Adds Int32 field to the row.
AppendInt64Adds Int64 field to the row.
AppendInt8Adds Int8 field to the row.
AppendNullAdds NULL value to the row.
AppendSingleAdds Single field to the row.
AppendStringAdds String field to the row.
AppendTimeAdds Time field to the row.
AppendTimestampAdds TimeStamp field to the row.
BeginRowBegins a new row to be added.
CloseFinalizes and flushes the appends.
EndRowMarks the row as done, so that next row can be started with BeginRow.

Examples


var db as EinhugurDuckDB.Database = EinhugurDuckDB.Database.CreateInMemory()
var connection as EinhugurDuckDB.Connection = db.Connect()

// create a table
connection.SQLExecute("CREATE TABLE tblSomeData(Name String, Number Integer)")

if connection.Error then
    MessageBox(connection.ErrorMessage)
end if

// Testing the Appender
Dim a as EinhugurDuckDB.Appender = connection.CreateAppender("tblSomeData")

if not connection.Error then
    for i as Integer = 1 to 100
       a.BeginRow()
       a.AppendString("Some name " + i.ToString())
       a.AppendInt32(i)
       a.EndRow()
    next
    a.Close()
   
    // Read the count of added rows
    var records as EinhugurDuckDB.Recordset = connection.SQLSelect("SELECT Count(*) FROM tblSomeData")
   
    if connection.Error then
       MessageBox connection.ErrorMessage
       return
    end if
   
    MessageBox records.Int64Value(0,0).ToString() + " rows successfully appended"
   
else
    MessageBox connection.ErrorMessage()
end if

Supported Platforms:

  • macOS Intel 32 bit
  • macOS Intel 64 bit
  • macOS Apple Silicon
  • Windows 32 bit
  • Windows 64 bit
  • Windows ARM 64 bit
  • Linux 32 bit
  • Linux 64 bit
  • Linux ARM 32 bit