Integrate hugo templates with Mysql database data

Hello,

Our requirement is to get sql data from MySql database and generate static pages using that data. I found a post dated in 1 MARCH 2015 (https://cyrillschumacher.com/2015/03/01/built-in-sql-support-for-gohugo.io/), where it was mentioned like, we can directly get sql data using select statements in template as of below. But, I got struck in 2 places, 1 with running " go build -tags alldb ." command, and after configuring HUGO_SQL_SOURCE environment variable and adding below code in template, I am getting “function “getSql” not defined” error.

I found almost no documentation other than the link attached for Hugo connectivity with databases. Would you please tell me, whether is there is any possibility to generate static html pages using data from MySql database as we intended or not? How we can do that ? or How we can get this “function “getSql” not defined” error resolved?

{{ range $i, $r := getSql “SELECT * FROM search_results }}
<div id=“id-1” class=“no-padding”>
<a href={{ $r.Column “url” }} target=”_blank" class=“font-weight-bold”>
{{ $r.Column “title” }}

<p>Last Updated: {{ $r.Column “last_updated” }}</p>
<p>…{{ $r.Column “description” }}…</p>
<a href={{ $r.Column “url” }} target=“_blank”>
{{ $r.Column “url” }}
</a>
</div>
{{end}}

Hi there,

getSql is not a Hugo function. See here.

Hugo does not support generating pages from databases.

Got you. Thanks!!

Hi @tiru417 ,

I am also getting the same error. How did you go about this error? Can you please help me…
I have downloaded the dependencies using go get -u -v github.com/spf13/hugo command as mentioned in https://github.com/SchumacherFM/hugo/tree/dynamicPagesWithGetSql as well. Still I am getting the same error.

Thank you