How to use the litecli.sqlcompleter.SQLCompleter function in litecli

To help you get started, we’ve selected a few litecli 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 dbcli / litecli / tests / test_naive_completion.py View on Github external
def completer():
    import litecli.sqlcompleter as sqlcompleter

    return sqlcompleter.SQLCompleter(smart_completion=False)
github dbcli / litecli / tests / test_smart_completion_public_schema_only.py View on Github external
def completer():

    import litecli.sqlcompleter as sqlcompleter

    comp = sqlcompleter.SQLCompleter()

    tables, columns = [], []

    for table, cols in metadata.items():
        tables.append((table,))
        columns.extend([(table, col) for col in cols])

    comp.set_dbname("test")
    comp.extend_schemata("test")
    comp.extend_relations(tables, kind="tables")
    comp.extend_columns(columns, kind="tables")

    return comp
github dbcli / litecli / litecli / completion_refresher.py View on Github external
def _bg_refresh(self, sqlexecute, callbacks, completer_options):
        completer = SQLCompleter(**completer_options)

        e = sqlexecute
        if e.dbname == ":memory:":
            # if DB is memory, needed to use same connection
            executor = sqlexecute
        else:
            # Create a new sqlexecute method to popoulate the completions.
            executor = SQLExecute(e.dbname)

        # If callbacks is a single function then push it into a list.
        if callable(callbacks):
            callbacks = [callbacks]

        while 1:
            for refresher in self.refreshers.values():
                refresher(completer, executor)
github dbcli / litecli / litecli / main.py View on Github external
self.completion_refresher = CompletionRefresher()

        self.logger = logging.getLogger(__name__)
        self.initialize_logging()

        prompt_cnf = self.read_my_cnf_files(["prompt"])["prompt"]
        self.prompt_format = (
            prompt or prompt_cnf or c["main"]["prompt"] or self.default_prompt
        )
        self.prompt_continuation_format = c["main"]["prompt_continuation"]
        keyword_casing = c["main"].get("keyword_casing", "auto")

        self.query_history = []

        # Initialize completer.
        self.completer = SQLCompleter(
            supported_formats=self.formatter.supported_formats,
            keyword_casing=keyword_casing,
        )
        self._completer_lock = threading.Lock()

        # Register custom special commands.
        self.register_special_commands()

        self.prompt_app = None