[sqlalchemy] Re: GRANT weirdness.
Yep that's it. If anyone has the same just do this: engine.execute('BEGIN;GRANT SELECT ON TABLE checkout_info TO testuser;COMMIT;') Ciao Koen On Apr 29, 4:51 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Apr 29, 2007, at 9:28 AM, Koen Bok wrote: > > > > > I want to grant permissions through sqlalchemy, but for some reason if > > I let an engine execute the sql it does not work: > > > Code: > > > from sqlalchemy import * > > > engine = create_engine('postgres://localhost/Test') > > engine.echo = True > > > engine.execute('CREATE USER testuser;') > > engine.execute('GRANT SELECT ON TABLE testtable TO testuser;') > > my only guess is that the GRANT needs a "COMMIT" issued afterwards > (which is a postgres weirdness in itself, that schema changes are > part of transactions). SA's autocommit logic is based on the > statement text containing INSERT, UPDATE, ALTER etc. but i dont think > GRANT is in there. so use an explicit connection/transaction for now. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: GRANT weirdness.
On Apr 29, 2007, at 9:28 AM, Koen Bok wrote: > > I want to grant permissions through sqlalchemy, but for some reason if > I let an engine execute the sql it does not work: > > Code: > > from sqlalchemy import * > > engine = create_engine('postgres://localhost/Test') > engine.echo = True > > engine.execute('CREATE USER testuser;') > engine.execute('GRANT SELECT ON TABLE testtable TO testuser;') my only guess is that the GRANT needs a "COMMIT" issued afterwards (which is a postgres weirdness in itself, that schema changes are part of transactions). SA's autocommit logic is based on the statement text containing INSERT, UPDATE, ALTER etc. but i dont think GRANT is in there. so use an explicit connection/transaction for now. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: GRANT weirdness.
And ofcourse the first result should be this in the above mail: > Test=# \z testtable >Access privileges for database "Test" > Schema | Name | Type | Access privileges > +---+---+ > public | testtable | table | {koen=arwdxt/koen} > (1 row) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---