How to use the databases.close_database function in databases

To help you get started, we’ve selected a few databases examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kynikos / outspline / src / outspline / interfaces / wxgui / notebooks.py View on Github external
def _handle_page_closing(self, event):
        # Veto the event, page deletion is managed explicitly later
        event.Veto()

        if core_api.block_databases():
            page = self.GetCurrentPage()
            databases.close_database(page.get_filename())
            core_api.release_databases()
github kynikos / outspline / src / outspline / interfaces / wxgui / dbprops.py View on Github external
def _proceed(self, event):
        # Close the properties tab explicitly, otherwise if the closing is
        # aborted, the choice controls should be reset to the current
        # configuration, if the tab is still open, which is not necessarily
        # true because the closing of the properties tab would race e.g. with
        # the dialogs to save the database
        self.propmanager.close(self.filename)

        if databases.close_database(self.filename):
            shutil.copy2(self.filename, self.backup.GetPath())

            if self.value == 0:
                dbdeps.Database(self.filename).add((self.ext, ))
            elif self.value == 1:
                dbdeps.Database(self.filename).remove((self.ext, ))
            else:
                dbdeps.Database(self.filename).remove((self.ext, ),
                                                                ignored=True)

            # Use CallAfter or segfaults may happen
            wx.CallAfter(databases.open_database, self.filename,
                                                        open_properties=True)
            # Note that no other operation should be done on the database
            #  directly here, because opening the database may fail e.g.
            #  because of the compatibility checks
github kynikos / outspline / src / outspline / interfaces / wxgui / menubar.py View on Github external
def close_all_databases(self, event, no_confirm=False, exit_=False):
        if core_api.block_databases():
            for filename in tuple(tree.dbs.keys()):
                if databases.close_database(filename, no_confirm=no_confirm,
                                                        exit_=exit_) == False:
                    core_api.release_databases()
                    return False
            else:
                core_api.release_databases()
                return True
github kynikos / outspline / src / outspline / interfaces / wxgui / menubar.py View on Github external
def close_database(self, event, no_confirm=False):
        if core_api.block_databases():
            treedb = wx.GetApp().nb_left.get_selected_tab()

            if treedb:
                databases.close_database(treedb.get_filename(),
                                                        no_confirm=no_confirm)
            core_api.release_databases()