[sqlalchemy] SQLAlchemy 1.0.4 Released

2015-05-07 Thread Mike Bayer

SQLAlchemy release 1.0.4 is now available.

With release 1.0.4 we are pretty much through all the bumps we had in 
the 0.9 to 1.0 movement. Four additional very minor regressions are 
solved in this release. Most prominently, another issue regarding recent 
enhancements to the Query.column_descriptions collection, also slated 
for release in 0.9.10, was fixed.


Changelog for 1.0.4 is at: http://www.sqlalchemy.org/changelog/CHANGES_1_0_4

SQLAlchemy 1.0.4 is available on the download page at:

http://www.sqlalchemy.org/download.html

--
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] python customer function

2015-05-07 Thread Mike Bayer



On 5/7/15 9:10 AM, jo wrote:

Hi all,

I would like to create a python customer function to extract data from a
table column and return a calculated value as in:

def birth(data):
   mm =
dict(A='01',B='02',C='03',D='04',E='05',H='06',L='07',M='08',P='09',R='10',S='11',T='12')
   return '19'+data[6:8] +'-'+ mm[data[8:9]] +'-'+ data[9:11]



sa.func.to_date( birth(Anagrafica.c.dato_fiscale), '-mm-dd'))



in: Anagrafica.c.dato_fiscale='ZZZHHH54M11Z128Y'
out: '1954-08-11'

How can I do this in a sqlalchemy query?


look into using the extract() function:

http://docs.sqlalchemy.org/en/rel_1_0/core/sqlelement.html?highlight=extract#sqlalchemy.sql.expression.extract

it mostly works the same on all backends, here's PG's docs:

http://www.postgresql.org/docs/8.1/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT





thanks for any help.
j
--
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.


--
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] Default column value before an object is commited

2015-05-07 Thread Anton


On Wednesday, May 6, 2015 at 8:03:54 PM UTC-7, Michael Bayer wrote:
>
>  Well it's already weird that you're defining both "default" and 
> "server_default" at the same time on the Column.  I'm not actually sure 
> what effect that would have and am surprised it doesn't fail in some 
> way...or at least renders the "server_default" more or less unused.
>

I have server_default for alembic. Alembic does not pick defaults, but does 
pick up server_default where generates migration files for DB structure. 
This is useful if rows are inserted outside of ORM.
 

>
> If you're just defining defaults as constants I'd think you only need 
> "default.arg" and that's it.   
>
I may have either callables or scalars.

> if it might be callable, the Python builtin callable() will do that for 
> you, is_callable is just a shortcut to having to call that internally.
> Those are all non-underscored attributes so they are public and safe to use.
>
Got it.

Thanks, 
Anton.

-- 
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.


[sqlalchemy] python customer function

2015-05-07 Thread jo


Hi all,

I would like to create a python customer function to extract data from a
table column and return a calculated value as in:

def birth(data):
  mm =
dict(A='01',B='02',C='03',D='04',E='05',H='06',L='07',M='08',P='09',R='10',S='11',T='12')
  return '19'+data[6:8] +'-'+ mm[data[8:9]] +'-'+ data[9:11]



sa.func.to_date( birth(Anagrafica.c.dato_fiscale), '-mm-dd'))



in: Anagrafica.c.dato_fiscale='ZZZHHH54M11Z128Y'
out: '1954-08-11'

How can I do this in a sqlalchemy query?

thanks for any help.
j

-- 
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.