I am running into some issues running fetchall().
I have a table defined like this:
with bookDB:
bookCur = bookDB.cursor()
bookCur.execute("CREATE TABLE Books(bookID INTEGER PRIMARY KEY, Title TEXT, Author TEXT, Genre TEXT)")
bookCur.close()
Now if I want to search the database for books by genre, I have this code:
with bookDB:
bookCur = bookDB.cursor()
bookCur.execute("SELECT * FROM Books WHERE Genre=?",(query,))
booklist=bookCur.fetchall()
book = ''.join(str(i) for i in booklist)
bookCur.close()
return book;
I would like to join all the items in the book list to make one string that is assigned to book but when I do this, all the TEXT fields arein the unicode format (u'TEXTHERE') and the front and end parentheses also stay. I know I can use split multiple times or delmitters, but there must be something I am doing wrong. How do I stop this from happening? Any tips?
Here is what I get back from fetchall:
[(133, u'Jurassic Park', u'Crichton', u'Sci-Fi')]
I would like a string like this
133>>Jurassic Park>>Crichton>>Sci-Fi
To send back through a socket.
Thank you very much in advance for any help.