Hello,
I'm trying to use SQLAlchemy with a custom PL/R
<http://www.joeconway.com/plr/doc/index.html> function. My PL/R function
returns a "RECORD" type, so it requires a column definition list. I'm
trying to replicate this in SQLAlchemy:
SELECT * FROM diffindiff('dc', '{"bronx"}', '2014-01-01') AS t(est FLOAT,
stderr FLOAT, tstat FLOAT, pval FLOAT);
So far this is what I have:
+ q = session.query(func.diffindiff(target, comparisons, date))
+ results = q.all()
The error message is:
/mnt/pricing-fraud/ve/lib/python2.7/site-packages/sqlalchemy/engine/base.pyc
in _execute_clauseelement(self, elem, multiparams, params)
[416/543]
1008 compiled_sql,
1009 distilled_params,
-> 1010 compiled_sql, distilled_params
1011 )
1012 if self._has_events or self.engine._has_events:
/mnt/pricing-fraud/ve/lib/python2.7/site-packages/sqlalchemy/engine/base.pyc
in _execute_context(self, dialect, constructor, statement, parameters, *args
)
1144 parameters,
1145 cursor,
-> 1146 context)
1147
1148 if self._has_events or self.engine._has_events:
/mnt/pricing-fraud/ve/lib/python2.7/site-packages/sqlalchemy/engine/base.pyc
in _handle_dbapi_exception(self, e, statement, parameters, cursor, context)
1330 util.raise_from_cause(
1331 sqlalchemy_exception,
-> 1332 exc_info
1333 )
1334 else:
/mnt/pricing-fraud/ve/lib/python2.7/site-packages/sqlalchemy/util/compat.pyc
in raise_from_cause(exception, exc_info)
197 exc_info = sys.exc_info()
198 exc_type, exc_value, exc_tb = exc_info
--> 199 reraise(type(exception), exception, tb=exc_tb)
200
201 if py3k:
/mnt/pricing-fraud/ve/lib/python2.7/site-packages/sqlalchemy/engine/base.pyc
in _execute_context(self, dialect, constructor, statement, parameters, *args
)
1137 statement,
1138 parameters,
-> 1139 context)
1140 except Exception as e:
1141 self._handle_dbapi_exception(
/mnt/pricing-fraud/ve/lib/python2.7/site-packages/sqlalchemy/engine/default.pyc
in do_execute(self, cursor, statement, parameters, context)
440
441 def do_execute(self, cursor, statement, parameters, context=None
):
--> 442 cursor.execute(statement, parameters)
443
444 def do_execute_no_params(self, cursor, statement, context=None):
ProgrammingError: (psycopg2.ProgrammingError) materialize mode required,
but it is not allowed in this context
CONTEXT: In PL/R function diffindiff
[SQL: 'SELECT diffindiff(%(diffindiff_2)s, %(diffindiff_3)s,
%(diffindiff_4)s) AS diffindiff_1'] [parameters: {'diffindiff_2': 'dc',
'diffindiff_3': ['bronx'], 'diffindiff_4': '2014-01-01'}]
I've tried variations on this with query.alias and query.label, to no
avail. Any thoughts?
Thanks,
Sam
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.