# Connect to DuckDB in FileMaker

**URL:** <https://the.fmsoup.org/t/connect-to-duckdb-in-filemaker/4809>\
**Category:** MBS Plugins\
**Tags:** sql, duckdb\
**Created:** [April 13, 2025, 8:12am UTC](https://the.fmsoup.org/t/connect-to-duckdb-in-filemaker/4809 "2025-04-13T08:12:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MonkeybreadSoftware](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/monkeybreadsoftware/32/361_2.png) [@MonkeybreadSoftware](https://the.fmsoup.org/u/MonkeybreadSoftware)\
**Post date:** [April 13, 2025, 8:12am UTC](https://the.fmsoup.org/t/connect-to-duckdb-in-filemaker/4809/1 "2025-04-13T08:12:27Z")

</div>

Today we like to connect to a DuckDB database from FileMaker using the [SQL](https://www.mbsplugins.eu/component_SQL.shtml) functions in [MBS FileMaker Plugin](https://www.monkeybreadsoftware.com/filemaker/). For that we need the client libraries for DuckDB, but where to get them?

### macOS with homebrew

For macOS you can use [homebrew](https://brew.sh/) to install the [duckdb](https://formulae.brew.sh/formula/duckdb#default) package. Then you get the duckdb library installed.

You find the library on an Apple Silicon Mac:

/opt/homebrew/Cellar/duckdb/1.2.1/lib/libduckdb.dylib

For an Intel Mac, you find it in the /usr/local folder in a sunfolder.

### All platforms

Just got to the DuckDB installation website: [Installation](https://duckdb.org/docs/installation/)

There you can click

- Version: Stable Release
- Environment: C/C++
- Platform: Pick yours
- Download method: Direct Download
- Architecture: Pick x86\_64 for Intel or arm64 for Apple Silicon

Then you can download the dylib/dll/so file and point the plugin to it.

### Connect

To connect, we then define a connection string with host, port and database name. Or for a local file, we just pass the file path.

```auto
Set Variable [$Connection ; Value: MBS("SQL.NewConnection")]
# Tell plugin where PostgreSQL library is
Set Variable [$result ; Value: MBS("SQL.SetConnectionOption"; $Connection; "DUCKDB.LIBS"; "/opt/homebrew/Cellar/duckdb/1.2.1/lib/libduckdb.dylib")]
# Connect to database
Set Variable [$result ; Value: MBS("SQL.Connect"; $Connection; "/Users/cs/Desktop/test.duckdb"; ""; ""; "DuckDB")]
If [$result ≠ "OK"]
    Show Custom Dialog ["Error: " & $result]
    Set Variable [$result ; Value: MBS("SQL.FreeConnection"; $Connection)]
Else
    # do something here
End If
# Cleanup
Set Variable [$result2 ; Value: MBS("SQL.FreeConnection"; $Connection)]

```

Once connected, you can do whatever queries you like to like the ones below:

```auto
// create command
$Command = MBS("SQL.NewCommand"; $Connection; "SELECT * FROM Test")
// run select
$result2 = MBS("SQL.Execute"; $Command)
// go to first row
$result3 = MBS("SQL.FetchNext"; $Command)
// result 3 is 1 if we got a record
// read first name field from result:
$firstname = MBS("SQL.GetFieldAsText"; $command; "FirstName")
// later release command
MBS("SQL.FreeCommand"; $Command)

```

Let us know if you have questions

---

<div class="post-metadata">

**Author:** ![planteg](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/planteg/32/627_2.png) [@planteg](https://the.fmsoup.org/u/planteg)\
**Post date:** [April 13, 2025, 10:08pm UTC](https://the.fmsoup.org/t/connect-to-duckdb-in-filemaker/4809/2 "2025-04-13T22:08:11Z")

</div>

A question for you not regarding DuckDB.

On macOS, you suggest to use HomeBrew to install DuckDB. I once used HomeBrew to install a package on BigSur for Intel. I had issues and tried to remove HomeBrew. That was painful to say the least., HomeBrew was always in the way, no sure process to remove it from MacOS. I swear I would never install it again. Was I unlucky ?

Thanks

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [April 14, 2025, 6:51am UTC](https://the.fmsoup.org/t/connect-to-duckdb-in-filemaker/4809/3 "2025-04-14T06:51:05Z")

</div>

> [@planteg](#):
>
> no sure process to remove it from MacOS. I swear I would never install it again. Was I unlucky ?

I suspect you were unlucky.

There is [the uninstall script](https://docs.brew.sh/FAQ#how-do-i-uninstall-homebrew) provided by HomeBrew. I'm not a huge fan of HomeBrew but it does allow me to install and maintain software packages that would be unavailable otherwise. The MacPorts project is an older alternative to HomeBrew.

---

<div class="post-metadata">

**Author:** ![MonkeybreadSoftware](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/monkeybreadsoftware/32/361_2.png) [@MonkeybreadSoftware](https://the.fmsoup.org/u/MonkeybreadSoftware)\
**Post date:** [April 14, 2025, 7:13am UTC](https://the.fmsoup.org/t/connect-to-duckdb-in-filemaker/4809/4 "2025-04-14T07:13:34Z")

</div>

Well, if you use homebrew, you get the dylib installed in

/opt/homebrew/Cellar/duckdb/1.2.1/lib/libduckdb.dylib

or without version:

/opt/homebrew/lib/libduckdb.dylib

It's convenient as it keeps them up to date just like a linux package manager.  
Not sure what your pain was with homebrew.

You can also just download the libduckdb.dylib from the [Installation](https://duckdb.org/docs/installation/) page and skip homebrew.
