Пример #1
0
def test_multi_sql():
    result = execute('', """
        sqlite://
        CREATE TABLE writer (first_name, last_name, year_of_death);
        INSERT INTO writer VALUES ('William', 'Shakespeare', 1616);
        INSERT INTO writer VALUES ('Bertold', 'Brecht', 1956);
        SELECT last_name FROM writer;
        """, {})
    assert 'Shakespeare' in str(result) and 'Brecht' in str(result)
Пример #2
0
def test_multi_sql():
    result = execute(
        '', """
        sqlite://
        CREATE TABLE writer (first_name, last_name, year_of_death);
        INSERT INTO writer VALUES ('William', 'Shakespeare', 1616);
        INSERT INTO writer VALUES ('Bertold', 'Brecht', 1956);
        SELECT last_name FROM writer;
        """, {})
    assert 'Shakespeare' in str(result) and 'Brecht' in str(result)
Пример #3
0
 def query(self, txt):
     return execute("", "%s %s" % (self.connectstr, txt))
Пример #4
0
def test_memory_db():
    execute('', 'sqlite:// CREATE TABLE test (n INT, name TEXT)')
    execute('', "sqlite:// INSERT INTO test VALUES (1, 'foo');")
    execute('', "sqlite:// INSERT INTO test VALUES (2, 'bar');")
    assert execute('', "sqlite:// SELECT * FROM test;")[0][0] == 1
    assert execute('', "sqlite:// SELECT * FROM test;")[1]['name'] == 'bar'
Пример #5
0
def test_plain_style():
    result = execute('', "sqlite:// SELECT * FROM test;",
                     {'style': 'PLAIN_COLUMNS'})
    assert re.search(r'1\s+foo', str(result))
Пример #6
0
def test_print():
    result = execute('', "sqlite:// SELECT * FROM test;")
    assert re.search(r'1\s+\|\s+foo', str(result))
Пример #7
0
def test_html():
    result = execute('', "sqlite:// SELECT * FROM test;")
    assert '<td>foo</td>' in result._repr_html_().lower()
Пример #8
0
def test_memory_db():
    execute('', 'sqlite:// CREATE TABLE test (n INT, name TEXT)')
    execute('', "sqlite:// INSERT INTO test VALUES (1, 'foo');")
    execute('', "sqlite:// INSERT INTO test VALUES (2, 'bar');")
    assert execute('', "sqlite:// SELECT * FROM test;")[0][0] == 1
    assert execute('', "sqlite:// SELECT * FROM test;")[1]['name'] == 'bar'
Пример #9
0
def test_plain_style():
    result = execute('', "sqlite:// SELECT * FROM test;", {'style': 'PLAIN_COLUMNS'})
    assert re.search(r'1\s+foo', str(result))
Пример #10
0
def test_print():
    result = execute('', "sqlite:// SELECT * FROM test;")
    assert re.search(r'1\s+\|\s+foo', str(result))
Пример #11
0
def test_html():
    result = execute('', "sqlite:// SELECT * FROM test;")
    assert '<td>foo</td>' in result._repr_html_().lower()