I've followed several examples to create and drop a DB2 table using SQLAlchemy within a python jupyter notebook. That works fine. But after creating the table, I need to set privileges so others can view it. I use this code to create a new table from a Pandas dataframe "df"
from sqlalchemy import create_engine, text
engine = create_engine(r"...")
df.to_sql(name='MYTABLE', schema='MYSCHEMA', con=engine, if_exists='replace', dtype=dashdb_typemap, index=False)
I can drop the table just fine with this code:
with engine.connect() as con:
con.execute('DROP TABLE MYSCHEMA.MYTABLE')
But neither of these work to set permissions:
with engine.connect() as con:
con.execute('GRANT ALL ON MYSCHEMA.MYTABLE TO PUBLIC')
with engine.connect() as con:
con.execute(text('GRANT ALL ON MYSCHEMA.MYTABLE TO PUBLIC'))
I can run the SQL in QMF and it works fine. It just doesn't seem to work from the notebook. I'm wondering if anyone sees the flaw I need to correct?
Thanks