2

For context, I am a newbie to python and in sqlite3 development.

I'd like to retrieve an integer value of the total records of a specific table using the SELECT clause statement in SQLITE3 using python3. How should I proceed in doing this?

My current code is:

    with conn:
    c.execute("SELECT COUNT (*) FROM normal_configuration")
    print(c.fetchone())

Output: (10,)

I was hoping I could retrieve just the integer but it's returning this. Can someone also explain to me why is this the output of this certain code? I would appreciate all the help and correction. Thank you!

1 Answers1

2

Like this:

with conn:
    c.execute("SELECT COUNT(*) FROM normal_configuration")
    result = c.fetchone()[0]
    print(result)
Mayank Porwal
  • 33,470
  • 8
  • 37
  • 58