[sqlalchemy] How to conditionally create an index in a clean way?

2015-06-08 Thread Adrian
Currently I have this code which does the job, but it feels extremely dirty:
https://gist.github.com/ThiefMaster/f7a7f7651245ec97a256

My `has_extension` function executes SQL to check if the given postgres 
extension is installed or not.
Something like DDL execute_if would be perfect, but from what I've seen 
it's not available on the Index class.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] How to conditionally create an index in a clean way?

2015-06-08 Thread Mike Bayer
The way this is supposed to work is to use the CreateIndex construct and 
apply it using events as described at 
http://docs.sqlalchemy.org/en/rel_1_0/core/ddl.html#controlling-ddl-sequences 
- that's where execute_if() is present.


But that's not working at the moment. 
https://bitbucket.org/zzzeek/sqlalchemy/issue/3442/no-control-of-ddl-sequences-for-indexes-fk 
is added.


As far as your current approach, I don't understand the has_extension 
thing, if that is the criteria for creating the index then I don't see 
how execute_if() would help, you'd still have to do that thing.







On 6/8/15 8:51 AM, Adrian wrote:
Currently I have this code which does the job, but it feels extremely 
dirty:

https://gist.github.com/ThiefMaster/f7a7f7651245ec97a256

My `has_extension` function executes SQL to check if the given 
postgres extension is installed or not.
Something like DDL execute_if would be perfect, but from what I've 
seen it's not available on the Index class.

--
You received this message because you are subscribed to the Google 
Groups sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to sqlalchemy+unsubscr...@googlegroups.com 
mailto:sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com 
mailto:sqlalchemy@googlegroups.com.

Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.