Content from different data source (database, sqlite)

I want to use hugo to render content from a different data source than textfiles. To be more concrete, i have existing entries in a sqlite database which i want to render with hugo. Is there a way (with a plugin?) to accomplish this and are there maybe examples already out there?

Currently, you would have to dump it to an intermediary format (CSV, JSON …), then read that. And the “dump operation” would have to be scripted outside of Hugo.

I’ve recently been experimenting with data and different formats for a current project.

I don’t know how you would directly bring in Sqlite, but I decided to work with CSV files using the getCSV function. if data conversion before Hugo is an option, you could convert each Sqllite table to csv file. Of course, indexiing won’t carry over.

My whole process has more to it, although nothing to do with sqlite, it might giive some ideas. I’m starting with an Excel file which is storing the data. A PHP script I adapted converts it to a usable CSV file.

By the way, what did you want Hugo to do with the data?

thanks for the replies. i want to use an existing book database (which has a few thousand entries in an sqlite db) and display content such as title, image, description with hugo.
regarding the getcsv function: where are you using this exactly? can you maybe post a code snippet?
i basically thought of replacing the content-loop where hugo gets the data from the files with sqlite calls, although this would maybe mean to create a fork of the hugo codebase.
if i have to use an intermediary format that would maybe also work - do you have an example on how to do this?


The getCSV function works in a range. I copied (almost verbatim) code from here which loops through the CSV file. An example is {{ range $key, value := getCSV $seperator $filepath }}, but better to find the info I used originally (which I guess was here or I googled it).

About this:

Don’t know how you make sql calls in Hugo. I’d think, depending on the data, it would be easier to convert the sql data to a usable format. If done out of the scope of Hugo, you could use any language you’re familiar with. My go-to language for this kind of thing is PHP, but sql is common enough that I’d assume a variety of languages could handle it.

EDIT: Just noticed post from bep which basciallly says this in a lot less words

A post was split to a new topic: GatsbyJS for Hugo