bdb.execute("drop table t")
bdb.execute("drop table if exists t")
with pytest.raises(apsw.SQLError):
bdb.execute("drop population p")
bdb.execute("drop population if exists p")
with pytest.raises(bayeslite.BQLError):
bdb.execute("drop generator p_cc")
bdb.execute("drop generator if exists p_cc")
with open(fname, "rU") as f:
bayeslite.bayesdb_read_csv(bdb, "t", f, header=True, create=True)
with bdb.savepoint():
// Savepoint because we don"t actually want the new data to
// be inserted.
with open(fname, "rU") as f:
bayeslite.bayesdb_read_csv(bdb, "t", f, header=True,
create=True, ifnotexists=True)
bdb.execute("""
create population p for t (
guess(*),
age numerical
)
""")
bdb.execute("create generator t_cc for t using crosscat ()")
with pytest.raises(bayeslite.BQLError):
// Redefining population.
bdb.execute("""
create population p for t (
guess(*),
age ignore
)
""")
with pytest.raises(bayeslite.BQLError):
// Redefining generator.
bdb.execute("create generator p_cc for p using crosscat")
// Make sure ignore columns work.
//
// XXX Also check key columns.
bdb.execute("""
create population p0 for t (
guess(*),
age ignore
)
""")
bdb.execute("drop population p0")
population_id = core.bayesdb_get_population(bdb, "p")
colno = core.bayesdb_variable_number(bdb, population_id, "age")
assert core.bayesdb_variable_stattype(bdb, population_id, colno) == \
"numerical"
bdb.execute("initialize 1 model for p_cc")
with pytest.raises(bayeslite.BQLError):
bdb.execute("drop table t")
with pytest.raises(bayeslite.BQLError):
bdb.execute("drop population p")
bdb.execute("drop generator p_cc")
with pytest.raises(bayeslite.BQLError):
bdb.execute("drop generator p_cc")
with pytest.raises(bayeslite.BQLError):
bdb.execute("drop table t")