Manlio Perillo wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Michael Bayer ha scritto:
>> [...]
>> In SQL (tested with PostgreSQL and SQLite, at least) I can do:
>> INSERT INTO test (text) values(to_tsvector('some text'));
>>
>> That is, it is possible to specify a scalar select statement for each
>> value.
>>
>>
>> Is this possible to do with SQLAlchemy?
>>
>> [...]
>>> OK you mean SQL expression during compilation. This is ticket #1534
>>> which is not yet implemented.
>
>
> After some tests I got something that works
> http://paste.pocoo.org/show/173099/
>
> The documentation seems to confirm this:
> http://www.sqlalchemy.org/docs/reference/sqlalchemy/expressions.html#sqlalchemy.sql.expression.insert
>
> SQLAlchemy still continues to surprise me!
> I need to download the documentation in PDF format, and take some time
> study it.
>
> I don't know if an example of this feature is available in the tutorial;
> if not, it should be added.
errr, you can put SQL expressions into insert.values(), but not in the
params sent to execute() (that was discontinued after 0.4). the example
you have is actually executing the sql.select() statement beforehand since
thats what "scalar()" does.
you're looking for
query = test.insert().values(text=sql.func.to_tsvector(u'some text'))
engine.execute(query)
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
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.