Exemple #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)
Exemple #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)
 def query(self, txt):
     return execute("", "%s %s" % (self.connectstr, txt))
Exemple #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'
Exemple #5
0
def test_plain_style():
    result = execute('', "sqlite:// SELECT * FROM test;",
                     {'style': 'PLAIN_COLUMNS'})
    assert re.search(r'1\s+foo', str(result))
Exemple #6
0
def test_print():
    result = execute('', "sqlite:// SELECT * FROM test;")
    assert re.search(r'1\s+\|\s+foo', str(result))
Exemple #7
0
def test_html():
    result = execute('', "sqlite:// SELECT * FROM test;")
    assert '<td>foo</td>' in result._repr_html_().lower()
Exemple #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'
Exemple #9
0
def test_plain_style():
    result = execute('', "sqlite:// SELECT * FROM test;", {'style': 'PLAIN_COLUMNS'})
    assert re.search(r'1\s+foo', str(result))
Exemple #10
0
def test_print():
    result = execute('', "sqlite:// SELECT * FROM test;")
    assert re.search(r'1\s+\|\s+foo', str(result))
Exemple #11
0
def test_html():
    result = execute('', "sqlite:// SELECT * FROM test;")
    assert '<td>foo</td>' in result._repr_html_().lower()