Re: [sqlalchemy] Re: SQLAlchemy 0.9.1 released

2014-01-07 Thread limodou
I found a problem in 0.9.1 version:

in 0.8.x :
 print (Blog.c.id==5)  None
blog.id = :id_1

But in 0.9.1:
 print (Blog.c.id==5)  None
blog.id = :id_1 AND NULL

So I don't know if it's a bug?


On Tue, Jan 7, 2014 at 2:25 AM, Jonathan Vanasco jonat...@findmeon.comwrote:

 automap sounds neat!  thanks!

 --
 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/groups/opt_out.




-- 
I like python!
UliPad The Python Editor: http://code.google.com/p/ulipad/
UliWeb simple web framework: https://github.com/limodou/uliweb
My Blog: http://my.oschina.net/limodou

-- 
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/groups/opt_out.


[sqlalchemy] Cubes OLAP 1.0alpha with new SQL backend features

2014-01-07 Thread Stefan Urbanek
Hi,

First, happy new year to you all and thanks for the great work on 
SQLAlchemy.

I just would like to share a bit of news. Cubes – Python Lightweight OLAP 
framework is approaching 1.0 with quite a few new things. Cubes is using 
SQLAlchemy for the SQL ROLAP backend. The notable SQL related changes are:

* multiple data stores[1] (databases/connections) per server session
* outer joins for dimensions [2] – allows you to include dimension members 
in the result even if there are no related facts.
* named model-wide join specification – you can specify a join (dimension 
table, column, type, ...) once in the model to be easily reused in any cube 
just by adding cube-specific attribute (just fact key(s))

The outer joins feature required a major rewrite of the SQL star schema 
browser. The nature of SQLAlchemy helped a lot.

Some notable non-SQL related changes:

* distinction between measures and aggregates
* new backends: Mongo, Mixpanel, Google Analytics, Slicer

More extensive list of 1.0 changes can be found at [3]

Note: There are many necessary backward incompatible changes. Please refer 
to the documentation for more information.

Links:

[1] http://cubes.databrewery.org/dev/doc/workspace.html
[2] http://cubes.databrewery.org/dev/doc/backends/sql.html#sql-outer-joins
[3] http://cubes.databrewery.org/dev/doc/releases/1.0.html

Comments, bug reports and questions are welcome. The Cubes Goggle Group 
is: https://groups.google.com/forum/#!forum/cubes-discuss

Cheers,

Stefan

-- 
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/groups/opt_out.


Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-07 Thread Michael Bayer
that’s this: 
http://docs.sqlalchemy.org/en/rel_0_9/changelog/migration_09.html#improved-rendering-of-boolean-constants-null-constants-conjunctions


On Jan 7, 2014, at 4:13 AM, limodou limo...@gmail.com wrote:

 I found a problem in 0.9.1 version:
 
 in 0.8.x :
  print (Blog.c.id==5)  None
 blog.id = :id_1
 
 But in 0.9.1:
  print (Blog.c.id==5)  None
 blog.id = :id_1 AND NULL
 
 So I don't know if it's a bug?
 
 
 On Tue, Jan 7, 2014 at 2:25 AM, Jonathan Vanasco jonat...@findmeon.com 
 wrote:
 automap sounds neat!  thanks!
 
 -- 
 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/groups/opt_out.
 
 
 
 -- 
 I like python!
 UliPad The Python Editor: http://code.google.com/p/ulipad/
 UliWeb simple web framework: https://github.com/limodou/uliweb
 My Blog: http://my.oschina.net/limodou
 
 -- 
 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/groups/opt_out.



signature.asc
Description: Message signed with OpenPGP using GPGMail


[sqlalchemy] matches_any: an extension to the Query object, and a HSTORE attribute access property

2014-01-07 Thread Philip Scott
Hi folks,

SQLAlchemy is at the heart of what we do at work (UK based hedge fund); so 
first of all a big thank you; I am not quite sure where we'd be without 
you. We would like to give back to the community as much as we can (I tried 
to get some of the developers on the company xmas present list this year 
but was too late.. cross your fingers for next year).

We have extended SQLAlchemy in a few places, though it is quite 
intermingled with our domain specific stuff I keep an eye out for little 
snippets that might be useful to others. So here's a trivial one; take it 
or leave it (and feel free to think of a better name). Knowing my luck it 
already exists; though I have looked hard through the docs!

class QueryEnhanced(Query):
''' Add a few extra bells and whistles to the standard Query object '''
def matches_any(self):
''' Returns true if your query would return 1 or more rows; false 
otherwise.
The following two statements ask the same question; but 
matches_any is _much_ quicker on large tables:
my_query.matches_any()
my_query.count() != 0
'''
return self.session.scalar(select([self.exists()]))

The other bit of technology we have that could be unpicked without _too_ 
much trouble is a sort of reverse CompositeProperty; many attributes of 
different types, including collections, out of one HSTORE column (with a 
sort of side-loaded instrumentation for mutation tracking that I think 
could have been done in a more idiosyncratic way). 

Paraphrasing a bit but you can do things like:

class Animal(Base):
data   = Column(MutableDict.as_mutable(HSTORE))

colour = HsProperty(data, String)
legs   = HsProperty(data, Integer)
discovered = HsProperty(data, Date)
fun_facts  = HsProperty(data, JSONEncoded(list))

'colour', 'legs', 'discovered', and 'fun_facts' end up as keys in the 
HSTORE and the values are strings, integers, dates and lists on the python 
side but stored as strings in the HSTORE such a way that they can be 
CAST-ed in a server query [where possible]:

session().query(Animal).filter(Animal.legs  2)

and get a query like

SELECT ... FROM animal WHERE CAST(animal.data - legs AS INTEGER)  2

You can also put an arbitrary JSONEncodable object in there too. 
Collections get converted to Mutable counterparts for change-tracking.

In many ways it is similar to ColumnProperty except that - the properties 
are writable (and when written only trigger the relevant bits of the hstore 
to be updated). Also on object instances the values in HsProperties are 
fetched as part of the query; we lazily de-serialise them directly from the 
hstore dictionary. 

Before spend a couple of days removing our corporate clutter from that, 
getting permission to license it etc.. and posting either as a patch or 
extension I thought I would see if there is any interest (or if someone has 
already done it better?). It's implemented as a custom metaclass right now, 
but I think I might be able to do it fully with events.

Code aside, if you can think of ways in which we as a company could support 
SQLAlchemy (bear in mind I am not in charge of the purse strings, but I can 
make a pitch on your behalf; we are still awaiting the fruits of our 
donation to the PyPy 
http://morepypy.blogspot.co.uk/2012/01/py3k-and-numpy-first-stage-thanks-to.htmlguys
 
:).** Then do let me know. I don't check this email account all that 
regularly but my work address is my firstname.lastname at cantabcapital dot 
com

Keep up the good work!

** [shameless plug] Or if you are keen, enthusiastic, mostly competent, and 
looking for a well paid job where you get to do loads of Python  SQLAlchemy

-- 
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/groups/opt_out.


Re: [sqlalchemy] matches_any: an extension to the Query object, and a HSTORE attribute access property

2014-01-07 Thread jason kirtland
On Tue, Jan 7, 2014 at 11:14 AM, Philip Scott safetyfirstp...@gmail.comwrote:

 Hi folks,

 SQLAlchemy is at the heart of what we do at work (UK based hedge fund); so
 first of all a big thank you; I am not quite sure where we'd be without
 you. We would like to give back to the community as much as we can (I tried
 to get some of the developers on the company xmas present list this year
 but was too late.. cross your fingers for next year).

 We have extended SQLAlchemy in a few places, though it is quite
 intermingled with our domain specific stuff I keep an eye out for little
 snippets that might be useful to others. So here's a trivial one; take it
 or leave it (and feel free to think of a better name). Knowing my luck it
 already exists; though I have looked hard through the docs!

 class QueryEnhanced(Query):
 ''' Add a few extra bells and whistles to the standard Query object '''
 def matches_any(self):
 ''' Returns true if your query would return 1 or more rows; false
 otherwise.
 The following two statements ask the same question; but
 matches_any is _much_ quicker on large tables:
 my_query.matches_any()
 my_query.count() != 0
 '''
 return self.session.scalar(select([self.exists()]))

 The other bit of technology we have that could be unpicked without _too_
 much trouble is a sort of reverse CompositeProperty; many attributes of
 different types, including collections, out of one HSTORE column (with a
 sort of side-loaded instrumentation for mutation tracking that I think
 could have been done in a more idiosyncratic way).

 Paraphrasing a bit but you can do things like:

 class Animal(Base):
 data   = Column(MutableDict.as_mutable(HSTORE))

 colour = HsProperty(data, String)
 legs   = HsProperty(data, Integer)
 discovered = HsProperty(data, Date)
 fun_facts  = HsProperty(data, JSONEncoded(list))

 'colour', 'legs', 'discovered', and 'fun_facts' end up as keys in the
 HSTORE and the values are strings, integers, dates and lists on the python
 side but stored as strings in the HSTORE such a way that they can be
 CAST-ed in a server query [where possible]:

 session().query(Animal).filter(Animal.legs  2)

 and get a query like

 SELECT ... FROM animal WHERE CAST(animal.data - legs AS INTEGER)  2

 You can also put an arbitrary JSONEncodable object in there too.
 Collections get converted to Mutable counterparts for change-tracking.

 In many ways it is similar to ColumnProperty except that - the properties
 are writable (and when written only trigger the relevant bits of the hstore
 to be updated). Also on object instances the values in HsProperties are
 fetched as part of the query; we lazily de-serialise them directly from the
 hstore dictionary.

 Before spend a couple of days removing our corporate clutter from that,
 getting permission to license it etc.. and posting either as a patch or
 extension I thought I would see if there is any interest (or if someone has
 already done it better?). It's implemented as a custom metaclass right now,
 but I think I might be able to do it fully with events.


I would be very interested in this work. At my org we have a subset of the
same idea that we're depending upon, but it's tied to an ancient SQLAlchemy
version and we never took it all the way into the query space like that.
That looks absolutely fabulous!

-- 
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/groups/opt_out.


Re: [sqlalchemy] matches_any: an extension to the Query object, and a HSTORE attribute access property

2014-01-07 Thread Michael Bayer

On Jan 7, 2014, at 2:14 PM, Philip Scott safetyfirstp...@gmail.com wrote:

 
 The other bit of technology we have that could be unpicked without _too_ much 
 trouble is a sort of reverse CompositeProperty; many attributes of different 
 types, including collections, out of one HSTORE column (with a sort of 
 side-loaded instrumentation for mutation tracking that I think could have 
 been done in a more idiosyncratic way). 
 
 Paraphrasing a bit but you can do things like:
 
 class Animal(Base):
 data   = Column(MutableDict.as_mutable(HSTORE))
 
 colour = HsProperty(data, String)
 legs   = HsProperty(data, Integer)
 discovered = HsProperty(data, Date)
 fun_facts  = HsProperty(data, JSONEncoded(list))
 
 'colour', 'legs', 'discovered', and 'fun_facts' end up as keys in the HSTORE 
 and the values are strings, integers, dates and lists on the python side but 
 stored as strings in the HSTORE such a way that they can be CAST-ed in a 
 server query [where possible]:
 
 session().query(Animal).filter(Animal.legs  2)
 
 and get a query like
 
 SELECT ... FROM animal WHERE CAST(animal.data - legs AS INTEGER)  2
 
 You can also put an arbitrary JSONEncodable object in there too. Collections 
 get converted to Mutable counterparts for change-tracking.
 
 In many ways it is similar to ColumnProperty except that - the properties are 
 writable (and when written only trigger the relevant bits of the hstore to be 
 updated). Also on object instances the values in HsProperties are fetched as 
 part of the query; we lazily de-serialise them directly from the hstore 
 dictionary. 
 
 Before spend a couple of days removing our corporate clutter from that, 
 getting permission to license it etc.. and posting either as a patch or 
 extension I thought I would see if there is any interest (or if someone has 
 already done it better?). It's implemented as a custom metaclass right now, 
 but I think I might be able to do it fully with events.

that’s a very nice pattern!  It looks like you could do that strictly with 
Python descriptors, such as subclassing @hybrid_property, no ?   Each property 
is just an expression against the “data” column, either python-side (lazily 
deserialize a key) or expression-side (do a postgresql expression for a certain 
key), and you can also trigger the mutable.is_changed() flag within the setter. 
  I don’t think you’d need events.

 
 Code aside, if you can think of ways in which we as a company could support 
 SQLAlchemy (bear in mind I am not in charge of the purse strings, but I can 
 make a pitch on your behalf; we are still awaiting the fruits of our donation 
 to the PyPy guys :).** Then do let me know. I don't check this email account 
 all that regularly but my work address is my firstname.lastname at 
 cantabcapital dot com

Thanks !   I think what I’m usually looking for are people resources.  Doc 
fixes and pull requests and such.   If I could organize some significant batch 
of work as something that would work under a “grant” model, I’ll let you know.  
 I haven’t figured out how to work that way, yet.




signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-07 Thread limodou
But I don't know why make this decision. Because where NULL will get
nothing. And in 0.8.X version, I need to combine multiple condition
according user input to one condition, so my code just like:

cond = None
for c in conditions:
cond = c  cond

So in 0.9.X, the result will be something like: WHERE todo.id = 1 AND NULL,
so I got nothing. Above code is totally wrong in 0.9.X.

And I think maybe the old way makes sence.


On Tue, Jan 7, 2014 at 10:42 PM, Michael Bayer mike...@zzzcomputing.comwrote:

 that’s this:
 http://docs.sqlalchemy.org/en/rel_0_9/changelog/migration_09.html#improved-rendering-of-boolean-constants-null-constants-conjunctions


 On Jan 7, 2014, at 4:13 AM, limodou limo...@gmail.com wrote:

 I found a problem in 0.9.1 version:

 in 0.8.x :
  print (Blog.c.id http://blog.c.id/==5)  None
 blog.id = :id_1

 But in 0.9.1:
  print (Blog.c.id http://blog.c.id/==5)  None
 blog.id = :id_1 AND NULL

 So I don't know if it's a bug?


 On Tue, Jan 7, 2014 at 2:25 AM, Jonathan Vanasco jonat...@findmeon.comwrote:

 automap sounds neat!  thanks!

 --
 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/groups/opt_out.




 --
 I like python!
 UliPad The Python Editor: http://code.google.com/p/ulipad/
 UliWeb simple web framework: https://github.com/limodou/uliweb
 My Blog: http://my.oschina.net/limodou

 --
 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/groups/opt_out.





-- 
I like python!
UliPad The Python Editor: http://code.google.com/p/ulipad/
UliWeb simple web framework: https://github.com/limodou/uliweb
My Blog: http://my.oschina.net/limodou

-- 
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/groups/opt_out.


Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-07 Thread Wichert Akkerman

On 08 Jan 2014, at 01:26, limodou limo...@gmail.com wrote:

 But I don't know why make this decision. Because where NULL will get 
 nothing. And in 0.8.X version, I need to combine multiple condition according 
 user input to one condition, so my code just like:
 
 cond = None
 for c in conditions:
 cond = c  cond

Why don’t you change the initial value to true() instead of None? If I read the 
documentation correctly that should work correctly in both SQLAlchemy versions.

Wichert.

-- 
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/groups/opt_out.


Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-07 Thread limodou
On Wed, Jan 8, 2014 at 3:31 PM, Wichert Akkerman wich...@wiggy.net wrote:


 On 08 Jan 2014, at 01:26, limodou limo...@gmail.com wrote:

  But I don't know why make this decision. Because where NULL will get
 nothing. And in 0.8.X version, I need to combine multiple condition
 according user input to one condition, so my code just like:
 
  cond = None
  for c in conditions:
  cond = c  cond

 Why don’t you change the initial value to true() instead of None? If I
 read the documentation correctly that should work correctly in both
 SQLAlchemy versions.


Even cond='' is correctly also, but I just think NULL is not a valid
condition expression in SQL, so I think the old appoach maybe better.

-- 
I like python!
UliPad The Python Editor: http://code.google.com/p/ulipad/
UliWeb simple web framework: https://github.com/limodou/uliweb
My Blog: http://my.oschina.net/limodou

-- 
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/groups/opt_out.