Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite IntegrityError while syncing #30

Open
JrtPec opened this issue Jul 10, 2017 · 0 comments
Open

SQLite IntegrityError while syncing #30

JrtPec opened this issue Jul 10, 2017 · 0 comments

Comments

@JrtPec
Copy link
Contributor

JrtPec commented Jul 10, 2017

Sometimes I run into this error while syncing a sensor:

File "D:\Python34\lib\site-packages\tmpo\__init__.py", line 253, in sync
    self._req_sync(sid, rid, lvl, bid)
  File "D:\Python34\lib\site-packages\tmpo\__init__.py", line 530, in _req_sync
    f.result(), sid, t["rid"], t["lvl"], t["bid"], t["ext"])
  File "D:\Python34\lib\site-packages\tmpo\__init__.py", line 546, in _write_block
    self.dbcur.execute(SQL_TMPO_INS, (sid, rid, lvl, bid, ext, now, blk))
sqlite3.IntegrityError: UNIQUE constraint failed: tmpo.sid, tmpo.rid, tmpo.lvl, tmpo.bid

My current solution is to just delete all TMPO-blocks for that sensor (see #27, implementation is on the way), after which I re-add the sensor and sync again. This causes a little bit of overhead, but it works fine.

However: doesn't this error just mean that the block we're trying to write already exists in the database? So we could deal with it in two ways:

  1. Assume the correct block is already written, so we can just ignore this insert.
  2. Assume the new block might be better, so overwrite the old one.

@icarus75 what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant