def test_duckdb_from_query(self, duckdb_cursor): # duckdb.from_query cannot be used to run arbitrary queries with pytest.raises(Exception) as e_info: duckdb.from_query('create view v1 as select 42 i') assert 'duckdb.query' in str(e_info.value) # ... or multiple select statements with pytest.raises(Exception) as e_info: duckdb.from_query('select 42; select 84;') assert 'duckdb.query' in str(e_info.value)
def test_query(self, duckdb_cursor): conn = duckdb.connect() conn.execute("create table t (a integer)") conn.execute("insert into t values (1)") assert duckdb.query("select count(*) from t", connection=conn).execute().fetchall()[0] == (1, ) assert duckdb.from_query( "select count(*) from t", connection=conn).execute().fetchall()[0] == (1, )
def test_fromquery(self, duckdb_cursor): assert duckdb.from_query('select 42').fetchone()[0] == 42 assert duckdb.query('select 43').fetchone()[0] == 43 # assert duckdb_cursor.from_query('select 44').execute().fetchone()[0] == 44 # assert duckdb_cursor.from_query('select 45').execute().fetchone()[0] == 45 # assert duckdb_cursor.from_query('select 45').execute().fetchone()[0] == 45 # cursor = duckdb.connect().cursor() # TestRelationApi().test_readonly(cursor)