How to use the litecli.main.LiteCli 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_main.py View on Github external
def output(monkeypatch, terminal_size, testdata, explicit_pager, expect_pager):
    global clickoutput
    clickoutput = ""
    m = LiteCli(liteclirc=default_config_file)

    class TestOutput:
        def get_size(self):
            size = namedtuple("Size", "rows columns")
            size.columns, size.rows = terminal_size
            return size

    class TestExecute:
        host = "test"
        user = "test"
        dbname = "test"
        port = 0

        def server_type(self):
            return ["test"]
github dbcli / litecli / tests / test_main.py View on Github external
def test_reserved_space_is_integer():
    """Make sure that reserved space is returned as an integer."""

    def stub_terminal_size():
        return (5, 5)

    old_func = click.get_terminal_size

    click.get_terminal_size = stub_terminal_size
    lc = LiteCli()
    assert isinstance(lc.get_reserved_space(), int)
    click.get_terminal_size = old_func
github dbcli / litecli / tests / test_main.py View on Github external
def output(monkeypatch, terminal_size, testdata, explicit_pager, expect_pager):
    global clickoutput
    clickoutput = ""
    m = LiteCli(liteclirc=default_config_file)

    class TestOutput:
        def get_size(self):
            size = namedtuple("Size", "rows columns")
            size.columns, size.rows = terminal_size
            return size

    class TestExecute:
        host = "test"
        user = "test"
        dbname = "test"
        port = 0

        def server_type(self):
            return ["test"]
github dbcli / litecli / tests / test_main.py View on Github external
def test_reserved_space_is_integer():
    """Make sure that reserved space is returned as an integer."""

    def stub_terminal_size():
        return (5, 5)

    old_func = click.get_terminal_size

    click.get_terminal_size = stub_terminal_size
    lc = LiteCli()
    assert isinstance(lc.get_reserved_space(), int)
    click.get_terminal_size = old_func
github dbcli / litecli / litecli / main.py View on Github external
execute,
    liteclirc,
):
    """A SQLite terminal client with auto-completion and syntax highlighting.

    \b
    Examples:
      - litecli lite_database

    """

    if version:
        print("Version:", __version__)
        sys.exit(0)

    litecli = LiteCli(
        prompt=prompt,
        logfile=logfile,
        auto_vertical_output=auto_vertical_output,
        warn=warn,
        liteclirc=liteclirc,
    )

    # Choose which ever one has a valid value.
    database = database or dbname

    litecli.connect(database)

    litecli.logger.debug("Launch Params: \n" "\tdatabase: %r", database)

    #  --execute argument
    if execute:
github chenjiandongx / fy / fy.py View on Github external
def records_prompt_shell():
    try:
        from litecli.main import LiteCli

        litecli = LiteCli(prompt="Type quit to exit shell.\nPrompt: ")
        litecli.connect(database=FY_DB_PATH)
        litecli.run_cli()
    except:
        print(huepy.red("sorry, it can't spawn records prompt shell."))
github sensepost / objection / objection / commands / sqlite.py View on Github external
click.secho('Validating SQLite database format', dim=True)
    with open(local_path, 'rb') as f:
        header = f.read(16)
        header = binascii.hexlify(header)

    if header != b'53514c69746520666f726d6174203300':
        click.secho('File does not appear to be a SQLite3 db. Try downloading and manually inspecting this one.',
                    fg='red')
        cleanup(local_path)
        return

    click.secho('Connected to SQLite database at: {0}'.format(db_location), fg='green')

    # boot the litecli prompt
    lite = LiteCli(prompt='SQLite @ {} > '.format(db_location))
    lite.connect(local_path)
    lite.run_cli()

    if _should_sync_once_done(args):
        click.secho('Synchronizing changes back...', dim=True)
        upload([local_path, full_remote_file])
    else:
        click.secho('NOT synchronizing changes back to device. Use --sync if you want that.', fg='green')

    # maak skoon
    cleanup(local_path)