Platforms to show: All Mac Windows Linux Cross-Platform

/SQL/SQLDatabaseMBS DuckDB


Required plugins for this example: MBS SQL Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /SQL/SQLDatabaseMBS DuckDB

This example is the version from Mon, 11th Apr 2021.

Project "SQLDatabaseMBS DuckDB.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() // use internal sqlite library call InternalSQLiteLibraryMBS.Use dim db as new SQLDatabaseMBS // where is the library? Dim f As FolderItem = SpecialFolder.Desktop.Child("libduckdb.dylib") db.SetFileOption(SQLConnectionMBS.kOptionLibraryDuckDB, f) // connect to database // in this example it is SQLite, // but can also be Sybase, Oracle, Informix, DB2, SQLServer, InterBase, MySQL, SQLBase and ODBC dim path as string if TargetMacOS then path = "/tmp/test.ddb" // put the database in the temporary folder else path = "test.ddb" // for Windows and Linux in the current folder the application is inside. end if db.DatabaseName = "DuckDB:"+path if db.Connect then MsgBox "We are connected!" // create table db.SQLExecute "Create table Test(fid integer, fvarchar20 varchar(20), fblob blob)" // insert value db.SQLExecute "Insert into Test(fid, fvarchar20) values (1, 'Hello World')" MsgBox("Table created, row inserted!") Dim r As RecordSet = db.SQLSelect("SELECT fid, fvarchar20 FROM Test") Dim n As Integer = r.IdxField(1).IntegerValue Dim s As String = r.IdxField(2).StringValue If n = 1 And s = "Hello World" then MsgBox "Got values: okay" Else MsgBox "Got values: failed" End If Else MsgBox db.ErrorMessage End If End EventHandler
End Class
Class Window1 Inherits Window
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

See also:

The items on this page are in the following plugins: MBS SQL Plugin.


The biggest plugin in space...