Grant user privileges

Issue #3326 closed
Leonardo Rossi created an issue

Exists the possibility to use SQLAlchemy to create user and grant privilege on the DB?

Comments (3)

  1. Mike Bayer repo owner

    absolutely. Easiest is to emit the desired GRANT statements using statement execution:

    engine = create_engine(...)
    engine.execute("GRANT ALL PRIVILEGES ON *.* TO moonbeam")
    

    if you want automatic GRANTs which can also be conditional based on backends, see the DDL system.

  2. Mike Bayer repo owner

    no. the differences in GRANT across databases are dramatically different not just in syntax but in semantics. For example, if you did a PG GRANT for a username, that won't work at all on MySQL - you need a hostname on MySQL as well. it's entirely not worth it at all to build such an API, it would be extremely complex and nobody would be using it, as it's more about configuration of the database itself.

  3. Log in to comment