I do a query in a sqlite database with Flask Python and it returns none when there are rows to read

0

I leave the code

@app.route("/")
def getInicio():
    conn=sqlite3.connect('datala.db')

    c = conn.cursor()

    row=c.execute('''SELECT * FROM servicio''')

    resultado =c.fetchone()

    print(resultado)


    conn.close()

    return "hola"
    
asked by user3739283 30.11.2018 в 12:59
source

1 answer

0

I tried your code (I modified it slightly) with a table of two columns:

import sqlite3

def getInicio():
    conn=sqlite3.connect("baseTabla.db")
    c = conn.cursor()
    row=c.execute("SELECT * FROM tabla")
    resultado =c.fetchall()
    for res in resultado:
      print(res)
    conn.close()

getInicio()

And it works without problems. You could check that the data really is in the file.

    
answered by 09.01.2019 в 20:26