I had hoped something as simple as:
Jobdtl.jobdtl_cmd
.replace("\t", "")
.replace("\n", "")
.replace("\r", "")
.label('command'),
Can you cast InstrumentedAttribute to a string and back?
As it stands you get:
AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator'
object associated with Jobdtl.jobdtl_cmd has an attribute 'replace'
On Friday, 9 February 2018 19:18:55 UTC, Jeremy Flowers wrote:
>
> I'm aware with Oracle I could probably do something like this:
> REPLACE(REPLACE(REPLACE(o.jobdtl_cmd, CHR(9), ''), CHR(10), ''), CHR(13),
> '') as COMMAND
>
> Is there a database agnostic way of doing this in SQLAlchemy?
>
> Would it be possible to provide a list of numbers, like 9,10,13, that
> would get iterated through to strip out the character and replace with an
> empty string?
>
> I was looking under func, thinking it maybe something you could do there...
>
> Perhaps via Register function?
>
> http://docs.sqlalchemy.org/en/latest/core/functions.html#sqlalchemy.sql.functions.register_function
>
> Does anyone have an example of a register function?
>
> Many thanks again.
>
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.