<div dir="ltr"><br><br>On Thu, Nov 22, 2018 at 11:33 PM Vaclav Petras <<a href="mailto:wenzeslaus@gmail.com">wenzeslaus@gmail.com</a>> wrote:<br>><br>><br>><br>> On Thu, Nov 22, 2018 at 10:57 AM Markus Metz <<a href="mailto:markus.metz.giswork@gmail.com">markus.metz.giswork@gmail.com</a>> wrote:<br>>><br>>><br>>><br>>> On Thu, Nov 22, 2018 at 3:31 PM Vaclav Petras <<a href="mailto:wenzeslaus@gmail.com">wenzeslaus@gmail.com</a>> wrote:<br>>> ><br>>> ><br>>> ><br>>> > On Wed, Nov 21, 2018 at 2:12 PM Martin Landa <<a href="mailto:landa.martin@gmail.com">landa.martin@gmail.com</a>> wrote:<br>>> >><br>>> >> Hi,<br>>> >><br>>> >> st 21. 11. 2018 v 20:05 odesílatel <<a href="mailto:svn_grass@osgeo.org">svn_grass@osgeo.org</a>> napsal:<br>>> >> > +        # clean the sqlite db<br>>> >> > +        from grass.script import db as gdb<br>>> >> > +        from grass.script import core as gcore<br>>> >> > +        conn = gdb.db_connection()<br>>> >> > +        if conn and conn['driver'] == 'sqlite':<br>>> >> > +           # check if db exists<br>>> >> > +           gisenv = gcore.gisenv()<br>>> >> > +           database = conn['database']<br>>> >> > +           database = database.replace('$GISDBASE', gisenv['GISDBASE'])<br>>> >> > +           database = database.replace('$LOCATION_NAME', gisenv['LOCATION_NAME'])<br>>> >> > +           database = database.replace('$MAPSET', gisenv['MAPSET'])<br>>> >> > +           if os.path.exists(database):<br>>> >> > +               message(_("Cleaning up sqlite database ..."))<br>>> >> > +               gcore.start_command('db.execute', sql = 'VACUUM')<br>>> >><br>>> >> a small note, the added code could be probably moved to new a fn eg.<br>>> >> clean_db(), Ma<br>>> ><br>>> ><br>>> > Yes, ideally to grass.script.setup.<br>>><br>>> But this is only initializing a GRASS session, without any mechanism to terminate a session. Basic usage in the documentation:<br>>><br>>>         # ... use GRASS modules here<br>>>         # remove the session's gisrc file to end the session<br>>>         os.remove(gisrc)<br>>><br>>> maybe a new fn to terminate a session is needed? This fn could clean temp files like clean_temp() in grass.py and also clean any default sqlite db when terminating the grass session.<br>><br>><br>> That's all correct. There would have to be more to make it the same procedure as in grass.py, but eventually we need to do that.<br>><br><div>> What I meant to add it to grass.script.setup module where we should eventually put all the functions needed to setup a proper GRASS session (or in some other module, but setup seems to be something good enough for now and moving things around while keeping the API is easy in Python).</div><div><br></div><div>ok, the db cleanup is now (r73704) a function in grass.script.setup</div><br></div>