MrTyton / Fanfiction-Recommendation

3 stars 0 forks source link

changed init #6

Closed MrTyton closed 8 years ago

MrTyton commented 8 years ago

Init function now works with the expanded tuple from the sql table 'stories', eg Story(*row). Will leave all other fields not in that row as blanks, you have to put them in manually from the other tables if you want.

MrTyton commented 8 years ago

Say you do "SELECT * FROM stories"; data = c.fetchone(), you get something like

(9068493, 4579051, u'Un amour assez complexe', 75, 1362398962, 1362398962, 1, 1, 0, u'Victorious', 0, u'French', u"Tara Whright est une jeune fille un peu timide voir beaucoup. Quand son pre, le clbre milliardaire, dcide de quitter Hollywood pour dmnager Buenos Aires et d'inscrire Tara au Studio 21, Tara ne sait plus o donner de la tte. Son incroyable don pour la chanson l'emmnera trs loin et pendant son chemin elle fera de magnifique rencontre et trouvera peut-tre l'amour...")

You can pass that into the story constructor by doing Story(*data)

MrTyton commented 8 years ago

The only fields that it won't populate in the Story object are url="", author="", tags=[], chapter_texts={}, but those can be gotten either from knowing that it's going to be "fanfiction.net/s/STORYID", lookups in the other tables, or calling get_chapter_texts()