Python Forum
Get last row of SQL database and update
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get last row of SQL database and update
#5
@Turtle, I overlooked the fact that you use aiosqlite, which you didn't mention explicitly, but was visible in the output. Anyway, according to docs it should work - there is an example.
Anyway, can you show the full traceback and ideally the full minimal reproducible code.

The strange thing is, that assuming db is Connection object, db.execute() should return Cursor object, which has .fetchone() method. However according to error it's Result object.

This should work, tested with sample дb

import aiosqlite
import asyncio

async def main():
    async with aiosqlite.connect('your_db.sqlite') as db:
        cursor = await db.execute("SELECT * FROM meetingData ORDER BY meeting_id DESC LIMIT 1")
        row = await cursor.fetchone()
        print(row)
        
        # rows = await cursor.fetchall()
        # print(rows)

        # async for row in cursor:
        #     print(row)
asyncio.run(main())
Turtle likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Get last row of SQL database and update - by Turtle - Oct-14-2021, 12:17 AM
RE: Get last row of SQL database and update - by buran - Oct-14-2021, 05:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Python + Google Sheet | Best way to update specific cells in a single Update()? Vokofe 1 2,714 Dec-16-2020, 05:26 AM
Last Post: Vokofe
Photo Update database in tkinter shahulvk 3 3,193 Oct-24-2020, 04:48 PM
Last Post: shahulvk
  How to update sql database from csv Prince_Bhatia 0 2,602 Feb-09-2019, 09:15 PM
Last Post: Prince_Bhatia
  add content of database to text widgte with update atlass218 1 2,603 Jan-06-2019, 02:13 AM
Last Post: woooee
  How to update only two colums in database from csv without touching data in other col Prince_Bhatia 0 2,296 Aug-21-2018, 09:13 AM
Last Post: Prince_Bhatia
  problem with select and update the data into the database chris0147 1 3,203 Aug-18-2017, 09:38 PM
Last Post: chris0147
  Search the data to update in a database chris0147 7 6,771 Oct-27-2016, 03:16 PM
Last Post: Ofnuts
  update the data into the database chris0147 3 6,259 Oct-19-2016, 12:12 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020