kerrickstaley / genanki

A Python 3 library for generating Anki decks
MIT License
1.99k stars 150 forks source link

Writing deck to file raises an exception. #5

Closed carllacan closed 7 years ago

carllacan commented 7 years ago

I get an error whenever I try to write a deck to file. It happens also with the example in the documentation, so it shouldn't be caused by the deck I am trying to create.

This is the output I get:

>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/carles/Desktop/kindletoanki/test.py", line 30, in <module>
    genanki.Package(my_deck).write_to_file('output.apkg')
  File "/home/carles/.local/lib/python2.7/site-packages/genanki-0.2.1-py2.7.egg/genanki/__init__.py", line 289, in write_to_file
    self.write_to_db(cursor, now_ts)
  File "/home/carles/.local/lib/python2.7/site-packages/genanki-0.2.1-py2.7.egg/genanki/__init__.py", line 302, in write_to_db
    deck.write_to_db(cursor, now_ts)
  File "/home/carles/.local/lib/python2.7/site-packages/genanki-0.2.1-py2.7.egg/genanki/__init__.py", line 271, in write_to_db
    note.write_to_db(cursor, now_ts, self.deck_id)
  File "/home/carles/.local/lib/python2.7/site-packages/genanki-0.2.1-py2.7.egg/genanki/__init__.py", line 232, in write_to_db
    '',                           # data
sqlite3.IntegrityError: NOT NULL constraint failed: notes.guid
carllacan commented 7 years ago

Solved. The problem was using Python 2.