Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL and fetchone
#5
sorry, I am not a nice English speaker. sometimes I mnot totally clear when I try to write what I think.
if I understand the real meaning of your answer, you say without the print everything is running nicely, don't you?
but I ran my code without it and I obtained the same result, I added it to know what is the matter.

so now my problem is solved, I just added an "or genre is null" like that:
cur.execute('''INSERT OR IGNORE INTO Genre (genre) 
        VALUES ( ? )''', (genre, ))
    cur.execute('SELECT id FROM Genre WHERE genre = ? OR genre IS NULL', (genre, ))
    genre_id = cur.fetchone()[0]
thanks for your help
Reply


Messages In This Thread
SQL and fetchone - by Scorpio - Feb-13-2019, 12:52 PM
RE: SQL and fetchone - by buran - Feb-13-2019, 01:37 PM
RE: SQL and fetchone - by Scorpio - Feb-13-2019, 04:54 PM
RE: SQL and fetchone - by buran - Feb-13-2019, 05:07 PM
RE: SQL and fetchone - by Scorpio - Feb-13-2019, 06:35 PM
RE: SQL and fetchone - by beebert69 - Oct-14-2020, 02:24 PM
RE: SQL and fetchone - by buran - Feb-13-2019, 06:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Convert SQLite Fetchone() Result to float for Math Extra 13 4,113 Aug-02-2022, 01:12 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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