SQLite Forum

FileIO extension
> I have been using SQLite3 (3.12.1) on my Mac

[I doubt that][1]. I'd bet you've actually been using [DB Browser for SQLite 3.12.1][2] (DB4S). Note the five-year span in release history and the difference in providers.

Beware that your question teeters on the edge of being off-topic here: we don't provide DB4S. It's only the fact that there's a way to answer your question using only SQLite that leads me to not brush you off and tell you to go ask the DB4S people, that being the software you're actually using and having trouble with, not SQLite proper.

> I have tried using terminal to no avail. 

One wonders why you didn't find [these generic instructions][3], or if you did, why you didn't show those commands in your question and show what they gave you, so we'd have a leg up on helping you.

To compile this particular extension from within [the SQLite source code tree][6], the generic instructions translate to this specific command on macOS:

      $ gcc -g -fPIC -dynamiclib -I. ext/misc/fileio.c -o ~/Desktop/fileio.dylib

The generic instructions don't tell you about the `-I.`, which you need in this case to ensure you get the right version of `sqlite3.h`, since the system version is found first otherwise, and it doesn't have all of the necessary definitions to compile against current SQLite.

> How to load the extension through DB Browser 

Select the Tools → Load Extension... menu item once you've got your DB open. 

The limitation of needing to have a DB open before you can load an extension is from DB4S, not something SQLite itself imposes, so [I've filed a bug for that weakness][4] for you.

> provide me with the exact code for loading through terminal;

That's covered in the SQLite documentation link above.

> Whether the extension will still be recognised if I copy the database to my PC or to another Mac

A compiled loadable extension is platform-specific by its nature, so yes, you'll need to have a built copy of this extension for each platform you use, if the DB schema or the commands you give to SQLite uses features from the extension.

If you want a given extension to be built statically into SQLite, you'll have to [build your own SQLite binaries][7], which are also be platform-specific.

The DB4S project provides instructions for doing the equivalent work in their docs, though for some reason their macOS guide is currently unwritten. Pursuing all of that is off-topic here.

> whether I will need to set the extension up each time.

For SQLite proper, you can list commands that occur on launch of the `sqlite3` shell by putting them in `~/.sqliterc`. (Not sure what the Windows equivalent is.) I have no idea if DB4S runs the `.sqliterc` file or if they have a similar but differently-designed alternative. Solving that isn't on-topic here.

> I am not technically trained

You wouldn't be the first person to learn some C simply in order to get some actual work done.

[1]: https://sqlite.org/changes.html#version_3_12_1
[2]: https://sqlitebrowser.org/blog/first-release-candidate-for-3-12-1/
[3]: https://www.sqlite.org/loadext.html#compiling_a_loadable_extension
[4]: https://github.com/sqlitebrowser/sqlitebrowser/issues/2733
[5]: https://github.com/sqlitebrowser/sqlitebrowser/wiki/Setting-up-a-Win64-development-environment-for-DB4S
[6]: https://sqlite.org/src/
[7]: https://www.sqlite.org/howtocompile.html