Forum Discussion
connecting a SQLite database
- 9 years ago
Hi,
You need to install a SQLite ODBC driver (look here: http://www.ch-werner.de/sqliteodbc) on your local machine. Then "Get Data" - "ODBC" and enter "database=C:\mysqlite.db" as connection string. This works at least for the PowerBI Desktop.
/Peter
If you're stuck because you can't install an ODBC driver in your environment (no admin rights, locked-down machine), here's another route: I've written a pure Power Query/M function that parses the SQLite file format directly.
No ODBC, no drivers, no dependencies at all.
The SQLite file format is stable and well documented, and most of the databases I encounter are tiny, so a full ODBC driver install always felt like a big ask for what is ultimately just reading a file.
You call it like this:
let
db = SQLite(File.Contents("C:\path\to\your.db")),
tbl = db{[Name = "my_table"]}[Data]
in
tblThe first call returns a navigation table of all tables in the database; the Data column drills into each one. Since it only needs the raw bytes, it also works with Web.Contents or SharePoint.Files. Which means it can even refresh in the Power BI Service without a gateway.
Code and documentation here: https://github.com/Hugoberry/PowerQuery-SQLiteReader
Main caveats: it's read-only, does full table scans (no SQL pushdown), and won't see un-checkpointed data from WAL-mode databases. Details in the README. For small-to-medium .db files, it works great.