News for hackers. Stuff that matters.
Re:Meet Korma, a SQL DSL for Clojure by jaylevitt on Thursday November 03, 2011 @08:11AM (#3191364)
Can SQLAlchemy core do arbitrary, non-ANSI things, like create a Postgres user-defined type or a SQL function?

And if so, can I use SQLAlchemy as a standalone pre-processor? My app's in Rails so I can't exactly go integrate it..

Re:Meet Korma, a SQL DSL for Clojure by zzzeek on Sunday November 06, 2011 @12:05PM (#3203143)
> Can SQLAlchemy core do arbitrary, non-ANSI things

yes. many DB specific constructs are included and you can make your own: http://www.sqlalchemy.org/docs/core/compiler.html

philosophically SQLA does not consider "abstraction" to be "hiding", so ultimately no features of the backend store are concealed

> like create a Postgres user-defined type

sure, the ENUM type does this right now automatically (i.e. CREATE TYPE...AS ENUM). For other kinds of PG types, you can emit the CREATE TYPE yourself then link to it with a SQLAlchemy-side custom type. You can integrate those two steps also.

> or a SQL function?

Again a SQL function you're going to be using PG's PL/pgSQL or other embedded language to create it, so you roll the CREATE FUNCTION yourself, then call it on the Python side using func: http://www.sqlalchemy.org/docs/core/tutorial.html#functions