roam-qgis / Roam

Simple data collection built using QGIS.
http://roam-docs.readthedocs.org/en/latest/
GNU General Public License v2.0
169 stars 61 forks source link

Photo DB Not Created #423

Open wcma-gis opened 5 years ago

wcma-gis commented 5 years ago

The Photo DB is not created automatically when setting up a form with a MultiPhoto widget. This could be overcome by creationg the table at runtime if it does not already exist.

The code also opens the database with the spatialite module, but that is not strictly necessary for a photo db.

    def DB(self):
        dbconfig = self.config['dboptions']
        dbpath = dbconfig['dbpath']
        dbpath = os.path.join(self.config['context']['project'].datafolder(), dbpath)
        table = dbconfig['table']
        db = sqlite3.connect(dbpath)
        db.enable_load_extension(True)
        db.load_extension("spatialite4.dll")
        sql = "CREATE TABLE IF NOT EXISTS '{0}' (linkid, photo, photo_id, timestamp, photo_number, linkname);".format(table)
        db.execute(sql)
        return db