How to use pgcli - 10 common examples

To help you get started, we’ve selected a few pgcli 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 / pgcli / tests / test_sqlcompletion.py View on Github external
def test_suggest_after_join_with_one_table(expression):
    suggestions = suggest_type(expression, expression)
    tables = ((None, "foo", None, False),)
    assert set(suggestions) == set(
        [
            FromClauseItem(schema=None, table_refs=tables),
            Join(((None, "foo", None, False),), None),
            Schema(),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_dot_suggests_cols_of_an_alias(sql):
    suggestions = suggest_type(sql, "SELECT t1.")
    assert set(suggestions) == set(
        [
            Table(schema="t1"),
            View(schema="t1"),
            Column(table_refs=((None, "tabl1", "t1", False),)),
            Function(schema="t1"),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_suggest_qualified_tables_views_functions_and_joins(expression):
    suggestions = suggest_type(expression, expression)
    tbls = tuple([(None, "foo", None, False)])
    assert set(suggestions) == set(
        [FromClauseItem(schema="sch", table_refs=tbls), Join(tbls, "sch")]
    )
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_sub_select_table_name_completion(expression):
    suggestion = suggest_type(expression, expression)
    assert set(suggestion) == set([FromClauseItem(schema=None), Schema()])
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_statements_with_cursor_after_function_body(text):
    suggestions = suggest_type(text, text[: text.find("; ") + 1])
    assert set(suggestions) == set([Keyword(), Special()])
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_suggest_qualified_tables_and_views(expression):
    suggestions = suggest_type(expression, expression)
    assert set(suggestions) == set([Table(schema="sch"), View(schema="sch")])
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_insert_into_lparen_partial_text_suggests_cols():
    suggestions = suggest_type("INSERT INTO abc (i", "INSERT INTO abc (i")
    assert suggestions == (
        Column(table_refs=((None, "abc", None, False),), context="insert"),
    )
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_distinct_and_order_by_suggestions_with_aliases(
    text, text_before, last_keyword
):
    suggestions = suggest_type(text, text_before)
    assert set(suggestions) == set(
        [
            Column(
                table_refs=(
                    TableReference(None, "tbl", "x", False),
                    TableReference(None, "tbl1", "y", False),
                ),
                local_tables=(),
                qualifiable=True,
            ),
            Function(schema=None),
            Keyword(last_keyword),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_select_suggests_cols_with_visible_table_scope():
    suggestions = suggest_type("SELECT  FROM tabl", "SELECT ")
    assert set(suggestions) == cols_etc("tabl", last_keyword="SELECT")
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_truncate_suggests_tables_and_schemas():
    suggestions = suggest_type("TRUNCATE ", "TRUNCATE ")
    assert set(suggestions) == set([Table(schema=None), Schema()])