Here´s my problem, I want to save a python 3.5-sqlite query in a variable, I created the following code:
import sqlite3
conn=sqlite3.connect('Database.db')
c=conn.cursor()
#this is implicit, but there is no xxx row in my table, condition and something
#arent real parameters for my query
qry=("SELECT xxx FROM xxx WHERE condition=something")
y=c.execute(qry)
print(y)
when I run this code I get the following in the print:
<sqlite3.Cursor object at 0x01FCD6A0>
now, if for example I used a for cycle to print this query:
for row in c.execute(qry): print(row)
I would have no problem, but I want to save the value that the query prints in a variable, it should be noted that I am trying to save a query that has a single row value, ex: ('EXAMPLE',)
Long story short, can I save a single row, single column query in a variable and then print it? should I install some module? this is actually for a project im working for
Aucun commentaire:
Enregistrer un commentaire