[sqlalchemy] Re: New plugins and data types
Thanks! Anyway I've seen that it's better add extensions in Elixir, into a declarative layer, just as has been made in DataMapper. http://elixir.ematia.de/apidocs/elixir.ext.html On 7 dic, 14:54, Michael Bayer [EMAIL PROTECTED] wrote: we have a bitbucket mirror athttp://www.bitbucket.org/mirror/sqlalchemy/ On Dec 7, 2008, at 5:01 AM, Kless wrote: I agree in that the SQLalchemy core been more centralized but would be very well if there would be a distributed version control where can be added easily new types. See as example to dm-more [1] -- of Datamapper--, where there are many contributions and many of them are very interesting. [1]http://github.com/sam/dm-more/tree/master/dm-types/lib/dm-types http://github.com/sam/dm-more/tree/master --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: New plugins and data types
On Mon, Dec 8, 2008 at 10:31, Kless [EMAIL PROTECTED] wrote: Thanks! Anyway I've seen that it's better add extensions in Elixir, into a declarative layer, just as has been made in DataMapper. As I just said on the Elixir mailing list: not really. The ability to add new types is an SQLAlchemy feature, not an Elixir one, so there is no reason to add them only at the Elixir level. That said, I'm not sure those types belong in SQLAlchemy core. It *might* make sense to have them in SQLAlchemy.ext namespace? http://elixir.ematia.de/apidocs/elixir.ext.html On 7 dic, 14:54, Michael Bayer [EMAIL PROTECTED] wrote: we have a bitbucket mirror athttp://www.bitbucket.org/mirror/sqlalchemy/ On Dec 7, 2008, at 5:01 AM, Kless wrote: I agree in that the SQLalchemy core been more centralized but would be very well if there would be a distributed version control where can be added easily new types. See as example to dm-more [1] -- of Datamapper--, where there are many contributions and many of them are very interesting. [1]http://github.com/sam/dm-more/tree/master/dm-types/lib/dm-types http://github.com/sam/dm-more/tree/master -- Gaƫtan de Menten http://openhex.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: sqlalchemy.func.sum
I cant find in the PG docs why it would raise this but the DISTINCT is not needed here. On Dec 8, 2008, at 6:05 AM, Ash wrote: Hello , I am usinng sqlalchemy for making the sum on column i am using sqlalchemy.func.sum (col_name). I am getting the error while dng it . Code snnipet aggregator=sqlalchemy.func.sum('product_sold') make_select = sqlalchemy.select(from_obj=[sales],columns= [aggregator],distinct=True) query = make_select.execute() result = query.fetchall() Error trace -- query = make_select.execute() File /var/lib/python-support/python2.5/sqlalchemy/sql/ expression.py, line 1087, in execute return e.execute_clauseelement(self, multiparams, params) File /var/lib/python-support/python2.5/sqlalchemy/engine/base.py, line 1219, in execute_clauseelement return connection.execute_clauseelement(elem, multiparams, params) File /var/lib/python-support/python2.5/sqlalchemy/engine/base.py, line 895, in execute_clauseelement return self._execute_compiled(elem.compile(dialect=self.dialect, column_keys=keys, inline=len(params) 1), distilled_params=params) File /var/lib/python-support/python2.5/sqlalchemy/engine/base.py, line 907, in _execute_compiled self.__execute_raw(context) File /var/lib/python-support/python2.5/sqlalchemy/engine/base.py, line 916, in __execute_raw self._cursor_execute(context.cursor, context.statement, context.parameters[0], context=context) File /var/lib/python-support/python2.5/sqlalchemy/engine/base.py, line 960, in _cursor_execute self._handle_dbapi_exception(e, statement, parameters, cursor) File /var/lib/python-support/python2.5/sqlalchemy/engine/base.py, line 942, in _handle_dbapi_exception raise exceptions.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect) sqlalchemy.exceptions.ProgrammingError: (ProgrammingError) function sum (unknown) is not unique Thanks in advance --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Remote query mapping without join
I'd like to be able to map read-only attributes based on a join, but without mapping the class to a joined table. Given this structure: class unit: pass class recsite: pass units = Table('units',metadata, Column('unit_id',Integer, primary_key=True,nullable=False), Column('recsite_id',Integer, ForeignKey(recsites.c.recsite_id), nullable=False)) recsites = Table('recsites',metadata, Column('recsite_id',Integer, primary_key=True,nullable=False), Column('depth',Integer,nullable=False)) mapper(unit,units) mapper(recsite,recsites) Is there a way to map a 'depth' property for unit, without mapping unit to units.join(recsites)? I tried adding a ColumnProperty to the mapper, but while it succeeds, it returns the wrong value: mapper(unit,units, properties={'depth':ColumnProperty(recsites.c.depth)}) I can't find anything in the documentation for ColumnProperty that tells me how to specify the join condition. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: Remote query mapping without join
On Dec 8, 2008, at 2:18 PM, channing wrote: I'd like to be able to map read-only attributes based on a join, but without mapping the class to a joined table. Given this structure: class unit: pass class recsite: pass units = Table('units',metadata, Column('unit_id',Integer, primary_key=True,nullable=False), Column('recsite_id',Integer, ForeignKey(recsites.c.recsite_id), nullable=False)) recsites = Table('recsites',metadata, Column('recsite_id',Integer, primary_key=True,nullable=False), Column('depth',Integer,nullable=False)) mapper(unit,units) mapper(recsite,recsites) Is there a way to map a 'depth' property for unit, without mapping unit to units.join(recsites)? I tried adding a ColumnProperty to the mapper, but while it succeeds, it returns the wrong value: mapper(unit,units, properties={'depth':ColumnProperty(recsites.c.depth)}) I can't find anything in the documentation for ColumnProperty that tells me how to specify the join condition. you would need to specify a correlated scalar select to ColumnProperty. The second example in http://www.sqlalchemy.org/docs/05/mappers.html#sql-expressions-as-mapped-attributes illustrates this. An alternative approach would be to build a relation() to a recsites mapper, but to use the association proxy so that you only see the depth attribute.Current docs for that are here http://www.sqlalchemy.org/docs/05/reference/ext/associationproxy.html but there's some errors in the examples on that page; I understand a new version of that document will be available shortly. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] subfilter to relation
hi back to that old question about relation vs query, i have some relation, say m2m via table with some additional fields like timestamps (which are setup automaticaly). so plain relation via secondary join is ok, no really need for explicit assoc_object. by default, the relation will give me all items, regardless of timing. now, i want to filter by times. it will be done by some function, which will have the timing context and ... what? the easiest answer is python-filtering: [x for x in the_relation if x.fits.filter ] but that would be very expensive. i dont want that relation loaded in full, it's meaningless. so, is it possible easy to obtain the query which the relation will issue, so i additionaly put .filter() on it and issue it myself? no changes to original relation. ciao svil --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: subfilter to relation
On Dec 8, 2008, at 3:49 PM, [EMAIL PROTECTED] wrote: hi back to that old question about relation vs query, i have some relation, say m2m via table with some additional fields like timestamps (which are setup automaticaly). so plain relation via secondary join is ok, no really need for explicit assoc_object. by default, the relation will give me all items, regardless of timing. now, i want to filter by times. it will be done by some function, which will have the timing context and ... what? the easiest answer is python-filtering: [x for x in the_relation if x.fits.filter ] but that would be very expensive. i dont want that relation loaded in full, it's meaningless. so, is it possible easy to obtain the query which the relation will issue, so i additionaly put .filter() on it and issue it myself? no changes to original relation. sure... query (A).join(A.bs).filter(B.whatever=='foo').options(contains_eager(A.bs)) or if you want the B's by themselves given an a query(B).with_parent(some_a, bs).filter(B.whatever=='foo') --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: subfilter to relation
On Monday 08 December 2008 23:39:57 Michael Bayer wrote: On Dec 8, 2008, at 3:49 PM, [EMAIL PROTECTED] wrote: hi back to that old question about relation vs query, i have some relation, say m2m via table with some additional fields like timestamps (which are setup automaticaly). so plain relation via secondary join is ok, no really need for explicit assoc_object. by default, the relation will give me all items, regardless of timing. now, i want to filter by times. it will be done by some function, which will have the timing context and ... what? the easiest answer is python-filtering: [x for x in the_relation if x.fits.filter ] but that would be very expensive. i dont want that relation loaded in full, it's meaningless. so, is it possible easy to obtain the query which the relation will issue, so i additionaly put .filter() on it and issue it myself? no changes to original relation. sure... query (A).join(A.bs).filter(B.whatever=='foo').options(contains_eager(A.b s)) or if you want the B's by themselves given an a query(B).with_parent(some_a, bs).filter(B.whatever=='foo') good, thanks. it smells to me like i need the relation/PropertyLoader but not the instrumented collection over it - or quite different one. lets see... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: subfilter to relation
On Monday 08 December 2008 23:39:57 Michael Bayer wrote: On Dec 8, 2008, at 3:49 PM, [EMAIL PROTECTED] wrote: hi back to that old question about relation vs query, i have some relation, say m2m via table with some additional fields like timestamps (which are setup automaticaly). so plain relation via secondary join is ok, no really need for explicit assoc_object. by default, the relation will give me all items, regardless of timing. now, i want to filter by times. it will be done by some function, which will have the timing context and ... what? the easiest answer is python-filtering: [x for x in the_relation if x.fits.filter ] but that would be very expensive. i dont want that relation loaded in full, it's meaningless. so, is it possible easy to obtain the query which the relation will issue, so i additionaly put .filter() on it and issue it myself? no changes to original relation. sure... query (A).join(A.bs).filter(B.whatever=='foo').options(contains_eager(A.b s)) or if you want the B's by themselves given an a query(B).with_parent(some_a, bs).filter(B.whatever=='foo') hmm, if i want to filter on a field in the m2m table? say it's not B.time, but table_A2B.time it comes in above query aliased, and i cant guess the selectable - and i think filter by table_A2B.c.time just wont work. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] preventing aliases
How can I prevent aliases fro appearing in the query? I have hit a MySQL bug that is related to a very biq SQL query string being sent and I am trying to shorten it. I might need an alias on one of the columns, though. The query is created originally by ORM query.compile() and then I create a UNION selection using union() of a couple of those. TIA Moshe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: preventing aliases
you'd need to be more specific what you mean by aliases (it sounds like you mean labels) and what the actual issue is. If its label names too long, use the latest 0.5 release candidate and set label_length=0 to create_engine(). also if you are using select() constructs generated by Query, again be on the 0.5 series and call Query.statement, you'll get the select() statement with the use_labels flag turned off. this is more appropriate if you are using the select()s inside of further constructs such as a union. On Dec 8, 2008, at 8:59 PM, Moshe C. wrote: How can I prevent aliases fro appearing in the query? I have hit a MySQL bug that is related to a very biq SQL query string being sent and I am trying to shorten it. I might need an alias on one of the columns, though. The query is created originally by ORM query.compile() and then I create a UNION selection using union() of a couple of those. TIA Moshe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---