How to display data from DB with JS in HTML site

I want to display data in a paragraph in a HTML file using JS. I have the following codes:

the button:

<button class = "buttonClickMe" onClick="showData();">Show Data</button>
<p>Here we will show some data</p>
<p id = "demo"></p>

the function to show data:

function showData(){
    sql = `SELECT * FROM MyTable`;
    
    db.all(sql, [], (err, rows)=>{
        rows.forEach((row)=>{
            console.log = row;
        })
    })
}

i tried displaying it using this code that i found

document.getElementById("demo").addEventListener("click", myFunction);

function myFunction() {   document.getElementById("demo").innerHTML = "this works"; }

But when i put the showData() function on the place of “this works” or change MyFunction, it says that “showData()” doesn’t return. When I write it without () it still doesn’t work. But it works when it is only “this works”

document.getElementById("demo").addEventListener("click", myFunction //doesnt work when using showData here//);

function myFunction() {
  document.getElementById("demo").innerHTML = "text"//doesnt work when using showData here//;
}

I tried using return statement in showData(), but I am not sure how I should return the data.