Re: [Shotwell] Repairing the event field in the database
- From: Dov Grobgeld <dov grobgeld gmail com>
- To: shotwell-list gnome org
- Subject: Re: [Shotwell] Repairing the event field in the database
- Date: Sun, 14 Jun 2015 09:08:13 +0300
There is a serious problem with the script that I posted in this list, which also appears to be the cause of the database problems that I have had. The problem is the row:
photo_df.to_sql("PhotoTable", con, if_exists='replace', index=False)
which will cause the PhotoTable to have the wrong "schema". The problem is that the Id variable will not be a "primary key", which will cause it not to autoincrement when inserting new photos into the database, and instead get a NULL value.
pandas provide an easy way to remedy this by the dtype keyword that was introduced in pandas 0.16.0:
dtype = {
"id": " INTEGER PRIMARY KEY",
"filename": "TEXT UNIQUE NOT NULL",
:
}
photo_df.to_sql("PhotoTable", con, if_exists='replace', index=False, dtype=photo_dtype)
Imo, it is a bug that shotwell does not validate the schema of the database, when opening it. It would have saved me plenty of time if it had...
I hope to create a github repo in the next couple of days with scripts for directly accessing the shotwell database.
Regards,
Dov
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]