Reputation: 27
i use this but i recive:<sqlite3.Cursor object at 0x00000253A4735960>* pls help with output
with sq.connect("WordBase.db") as con:
cur = con.cursor()
print(cur.execute('''SELECT * FROM word WHERE ROWID=1
'''))```
Upvotes: 0
Views: 277
Reputation: 5482
Execute is just an instruction to execute a SQL Statement
To retrieve data after executing a SELECT statement, either treat the cursor as an iterator, call the cursor’s fetchone() method to retrieve a single matching row, or call fetchall() to get a list of the matching rows.
Link to Documentation
Below are examples from a table built in the example on documentation
You can fetchall()
to return all the results
cur.execute('select * from lang')
cur.fetchall()
You can fetchone()
to return a single result
cur.execute('select * from lang')
cur.fetchone()
You can also use the cursor as an iterator
for i in cur.execute('select * from lang'):
i
Upvotes: 2