[sqlalchemy] event.remove failure
Hi, I started to play with events to port a library to sqla 0.7. I managed to use the 'listen' function but I failed on 'remove'. Looking at the signatures they seem to be just the same, but here is what I get: In [7]: event.listen(obj.__class__.title, 'set', listen_cb) In [8]: event.remove(obj.__class__.title, 'set', listen_cb) --- TypeError Traceback (most recent call last) /home/misc/src/hg/py/sqlkit-pub/demo/sql/demo.py in module() 1 2 3 4 5 /misc/src/sqlalchemy/sqlalchemy/lib/sqlalchemy/event.pyc in remove(target, identifie 69 70 for evt_cls in _registrars[identifier]: --- 71 for tgt in evt_cls._accept_with(target): 72 tgt.dispatch._remove(identifier, tgt, fn, *args, **kw) 73 return TypeError: 'InstrumentedAttribute' object is not iterable Did I misundertand the syntax or what else? TIA sandro *:-) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/SqqNPsbu8DsJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: event.remove failure
On 18 Ago, 16:52, Michael Bayer mike...@zzzcomputing.com wrote: remove() isn't implemented yet. While the simple operation you see below would be fine for a single listener on a single target, the targets we have which propagate to subclasses (mapper events, attribute events) would require a more elaborate system that can revisit everywhere the event has been propagated and remove it from there as well. this is why remove isn't published in the docs right now. Thanks, I wasn't carefull enought to realize it was not in the docs. I guessed there was such a function and I found it, so I tried to use it... In our own tests I use a hack to remove an entire set of listeners at once, if this is a testing teardown scenario you're dealing with. No really I would need it in a different setup. I have many GTK widgets that show some data that are in a session and I need to update the GUI whenever the data change. Otherwise, ad-hoc removal on a per operation basis ? I knew someone would try it though damned if I could imagine what possible use there could be for that. If this is the case here, care to entertain me ? Not sure what you mean exactly here, but if the point is: why I want to use 'remove'. It's just that when I destroy the GUI widget that displays data I'd like to remove the listener to be sure no reference tries to keep my object in memory. As of now I see that callbacks are still called. sandro *:-) -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: association_proxy introspection
On Tue, Mar 22, 2011 at 05:43:17AM -0700, sandro dentella wrote: Hi, i just discovered association_proxy and like it very much. It definetely helps in some situations. I already have a library that setup gui instrospecting the mapper, to allow editing and filtering of records. the only way I found to get the association_proxy of a class is checking its attributes:: for key, value in vars(d.t.mapper.class_).iteritems(): if isinstance(value, AssociationProxy): print key I can't find a way to get information on the column it is proxying, that would be needed to me in order to setup a proper representation: how can I find it? ok, the way is probably: target_col = obj_proxy.target_class.__table__.c[obj_proxy.value_attr] Please correct me if this is wrong or just not always right. This opens some questions on how to use it in a query that I leave for a separate thread. sandro -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] association_proxy introspection
Hi, i just discovered association_proxy and like it very much. It definetely helps in some situations. I already have a library that setup gui instrospecting the mapper, to allow editing and filtering of records. the only way I found to get the association_proxy of a class is checking its attributes:: for key, value in vars(d.t.mapper.class_).iteritems(): if isinstance(value, AssociationProxy): print key I can't find a way to get information on the column it is proxying, that would be needed to me in order to setup a proper representation: how can I find it? I see there's no property on the mapper, corresponding to an association_proxy, is it possible to instrospect the mapper and see get some info? thanks in advance sandro *:-) -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] attaching an AttributeExt to an existing mapper
Hi, is there a way to attach an attribute extension of an existing property of an (existing) mapper? I made some tests [1] and it seems that attaching the AttrExt to a mapper does not work: mapper.get_property('name').extension = MyAttrExt() Is there a way apart from setting it while creating the property? thanks in advance sandro *:-) [1] http://dpaste.com/hold/394115/ -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: mapper for outerjoin: getting None objects
Thanks as usual for your valuable and prompt response sandro *:-) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] LONGVARCHAR
Hi, firefox uses sqlite to store bookmark info. The file is called places.sqlite and the schema has type LONGVARCHAR for some fields and LONG for another. Autoloading that with sqlalchemy maps that columns to NullType rather that to a String / Integer one. Same for LONG type I don't really know if LONGVARCHAR/LONG are correct types for sqlite but they are accepted and used: is it possible to make sqlalchemy autoload correctly? Or should we ask firefox guys to use different types? sandro *:-) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: CircularDependencyError on 0.6 (works on 0.5.8)
On 26 Ago, 18:41, Michael Bayer mike...@zzzcomputing.com wrote: of course you'll get a cycle if you do this, though: s1 = School(cod=S1, cod_riferimento=S1, cliente=False) d1 = School(cod=D1, cod_riferimento=S1, cliente=False) s1.sedi = [s1, d1] That was it! now I got it. thanks. s1-s1 is not supported by self referential flushes, unless you put post_update=True on the relation() you have there. that works Thanks as usual for your great support sandro *:-) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] upgrading code with prop.backref from 0.5 - 0.6
Hi, Let's start with the simple example based on movie/director example class Director(Base): __tablename__ = 'director' id = Column(Integer, primary_key=True) last_name = Column(String(60), nullable=False) movies = relation('Movie', backref='director', cascade='all, delete-orphan',) class Movie(Base): __tablename__ = 'movie' id = Column(Integer, primary_key=True) title = Column(String(60), nullable=False) director_id= Column(Integer, ForeignKey('director.id'), nullable=False) Due to delete-orphan cascading rule when creating a movie object I need to attach a director object. In a table editor when setting a foreign key I parse all the properties to see if someone requires such 'director' obj so that I can easily fetch it and attach. The working code in 0.5 is as follows: def get_props_for_delete_orphan(mapper, field_name): discover if field_name setting needs to set an object to fullfill the request for a delete_orphan cascading on a possible relation returns the generator for the properties or () prop = mapper.get_property(field_name) assert isinstance(prop, properties.ColumnProperty) assert len(prop.columns) == 1 # I don't handle mapper with two columns in a property column = prop.columns[0] props = [] for pr in mapper.iterate_properties: if isinstance(pr, properties.RelationProperty): if pr.direction.name in ('MANYTOONE',): for col in pr.local_remote_pairs[0]: # I can't use col in p.local_remote_pairs # as it uses 'col == p.local_remote_pairs' that evaluates # to a BinaryExpression if column is col: try: if pr.backref.prop.cascade.delete_orphan: props += [pr] except AttributeError, e: pass return tuple(props) This fails in sqla 0.6 as pr.backref is empty. Which is the correct way to get the properties that have a backref that have cascade with delete_orphan? thanks sandro *:-) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: mappers and non_primary arg
Please, can anybody tell me what's the meaning of 'non_primary' arg of mapper function. I probably misunderstood it but I'd like to know what it is meant for. thanks sandro On Thu, Jul 01, 2010 at 10:41:44AM -0700, sandro dentella wrote: Hi, I'm trying to use non_primary arg of function 'mapper'. Currently I have a GUI widget to browse/edit tables that is based on introspection of the mapper. My goal would be to reuse all the machinary of table browsing even when browsing tables that where built w/o primary key. I'm ready to understand that I can't use persistence but I thought that flagging as a non primary mapper I could assemble a mapper even from a table missing a primary_key, that's what I thought was the meaning of: Construct a Mapper that will define only the selection of instances, not their persistence. What I get is: ipdb mapper(X, table, non_primary=True) *** ArgumentError: Mapper Mapper|lavori_class|lavori|non-primary could not assemble any primary key columns for mapped table 'lavori' So what's the real meaning of primary_key? thanks sandro *:-) -- Sandro Dentella *:-) http://sqlkit.argolinux.orgSQLkit home page - PyGTK/python/sqlalchemy -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] mappers and non_primary arg
Hi, I'm trying to use non_primary arg of function 'mapper'. Currently I have a GUI widget to browse/edit tables that is based on introspection of the mapper. My goal would be to reuse all the machinary of table browsing even when browsing tables tat where built w/o primary key. I'm ready to understand that I can't use persistence but I thought that flagging as a non primary mapper I could assemble a mapper even from a table missing a primary_key, that's what I thought was the meaning of: Construct a Mapper that will define only the selection of instances, not their persistence. What I get is: ipdb mapper(X, table, non_primary=True) *** ArgumentError: Mapper Mapper|lavori_class|lavori|non-primary could not assemble any primary key columns for mapped table 'lavori' So wht's the real meaning of primary_key? thanks sandro *:-) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: declarative + order_by of 2 columns: is it possible?
Hi, On 11 Mag, 18:23, sandro dentella san...@e-den.it wrote: Hi, i have a working declarative configuration that has a relation as this:: client = relation(Cliente, backref='jobs' , lazy=False, order_by=status.desc) now I'd like to add a second column in the order_by field but adding a list doesn't seem to work. I tried: client = relation(Cliente, backref='jobs' , lazy=False, order_by=[status.desc, description]) before posting the error I'd like to understand if that should be correct as I don't find in the docs the correct syntax, I just find the syntax for order_by method of query. sorry for reposting, but I can't even understnd if the above syntax should be allowed or not. According to docs for 'relation': order_by – indicates the ordering that should be applied when loading these items. doesn't meant it accepts more than one column, order_by for query does... It's not vital but I'd like to know if it's possible and I'm just misinterpreting the syntax. thanks sandro -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] declarative + order_by of 2 columns: is it possible?
Hi, i have a working declarative configuration that has a relation as this:: client = relation(Cliente, backref='jobs' , lazy=False, order_by=status.desc) now I'd like to add a second column in the order_by field but adding a list doesn't seem to work. I tried: client = relation(Cliente, backref='jobs' , lazy=False, order_by=[status.desc, description]) before posting the error I'd like to understand if that should be correct as I don't find in the docs the correct sintax, I just find the syntax for order_by method of query. thanks sandro *:-) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: Type of Column added with column_property
Just to be clearer: if I used func.count, the property is correctly set to Intege type. How can I create a column in the mapper and have the column reflect the real type in the db. I do introspections in columns to prepare the gui to display it and to add filters on that field (http://sqlkit.argolinux.org/sqlkit/ filters.html) and that would help a lot. thanks in advance sandro *:-) On 15 Dic, 19:58, Alessandro Dentella san...@e-den.it wrote: Hi, is there a way to set the type of a column added to a mapper with column_property? m = mapper(New, t, properties={ 'my_bool': column_property( func.my_bool(t.c.id, type=Boolean) ) }) func 'my_bool' is a stored procedure on Postgresql and returns a boolean, but the type of the column is NullType: m.get_property('my_bool').columns[0].type NullType() -- Sandro Dentella *:-)http://sqlkit.argolinux.org SQLkit home page - PyGTK/python/sqlalchemy -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Doubts on relation with cascade delete by backend
Hi, I have a simple setup that may be summarized as: class User(Base): __tablename__ = 'user' name = Column(String(20), primary_key=True) class Mail(Base): __tablename__ = 'address' mail = Column(String(20), primary_key=True) user_name = Column(ForeignKey(User.name, ondelete=CASCADE), nullable=False) the generated DDL allows deletion of a user also in case it has associated addresses thanks to the ON DELETE CASCADE. If I try to delete the object from sqlalchemy I get an error, since SA tries to set úser_name'attribute to NULL that is forbidden by the NOT NULL constraint. I can add a relation that will fix things by adding a backref: user = relation(User, backref=backref('addresses', cascade='all, delete- orphan')) Is there a way to obtain that any cascading is left to the backend? (pg in my case). I have not been able to find references but I'm sure I saw some discussion on that already... Thanks in advance sandro *:-) --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] compound ForeignKeyConstraint
Hi, which is the correct way to see if a ForeignKey in the set column.foreign_key is part of a compound ForeignKeyConstraint? thanks in advance sandro --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: creating objects in after_flush hook
I correct myself On 12 Mag, 11:05, Alessandro Dentella san...@e-den.it wrote: Hi, in a sessionExtension.after_flush hook I create objects (namely todo actions depending on what people have inserted/updated). At present I create these objects in the current session, but I do understand is not clean as the flush has already occurred. It almost works, objects are really created but are left in the dirty set. I didn't realize I entered twice in the after_flush... I guess once the first 'normal' and the second for the newly created object. This seems to confirm the fact that we can create objects even from withing the after_flush hook and have them saved in the same session. Good! sandro --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: puzzling outerjoin in the mapper
Thanks. I do appreciate that this will become the default as I think that if you ask for an outer join that's what you expect. thanks again for you time sandro --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: puzzling outerjoin in the mapper
Missing an answer I opened ticket #1392: http://www.sqlalchemy.org/trac/ticket/1392#preview --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: puzzling outerjoin in the mapper
Hi, Mike, should I file a ticket for this?... or I just misinterpreted the result? sandro *:-) --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Attempting to flush an item of type...
the solution was to inherit setup.USER with a non-relative path fossati.models.client.User. I misinterpreted the words 'whose mapper...' and believed it was referencing Entry.user while it is referred to setup.USER. sandro --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: availability of related obj
as soon as Ticket is persistent within the flush, the ticket.assigned_to relation will be live and will lazy load when accessed. no commit is needed. mmh, in the following example, I can't use assigned_to within after_flush. Am I doing something wrong? from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Table, Column, ForeignKey, text, func from sqlalchemy.types import * from sqlalchemy.orm import relation, sessionmaker from sqlalchemy.orm.interfaces import SessionExtension Base = declarative_base() Base.metadata.bind = 'sqlite://' class User(Base): __tablename__ = 'user' id = Column(Integer, primary_key=True) username = Column(String(20)) class Ticket(Base): __tablename__ = 'ticket' id = Column(Integer, primary_key=True) assigned_to_id = Column(ForeignKey(User.id)) assigned_to = relation(User, primaryjoin = assigned_to_id == User.id, lazy=True) class SKSessionExtension(SessionExtension): def after_flush(self, session, flush_context): implement the after-flush signal for new in session.new: if isinstance(new, Ticket): print NEW: %s - assigned_to: %s % ( new, new.assigned_to) Session = sessionmaker(bind=Base.metadata.bind) session = Session(extension=SKSessionExtension()) Base.metadata.create_all() #Base.metadata.bind.echo = True user = User() user.username = 'aaa' session.add(user) session.commit() ticket = Ticket() ticket.assigned_to_id = user.id session.add(ticket) session.flush() print AFTER FLUSH, ticket.assigned_to session.commit() print AFTER COMMIT, ticket.assigned_to -- that leads to this output: NEW: __main__.Ticket object at 0x84f51cc - assigned_to: None AFTER FLUSH None AFTER COMMIT __main__.User object at 0x84f060c sandro --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: availability of related obj
specifically the lazy loader will work in the after_flush_postexec() phase of the sessionextension. during after_flush(), the post-flush bookkeeping has not been establishsed yet on assigned_to_id, and the lazy loader always looks for the persisted version of the attribute. ok, this explains my example in fact, that really means I cannot use that relation in after_flush. after_lush_postexec is too late as I need session.dirty/session.new to be able to understand what happened and take actions consequently. thanks sandro --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: remove an object from a property deletes from session
On 26 Mar, 18:04, Michael Bayer mike...@zzzcomputing.com wrote: it would only do that if you have delete-orphan on the relation, and the object was never saved.it will get re-added once you attach it to that's exactly the situation I have. thanks for the explanation. sandro *:-) --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: getting referenced *class* from relation
thanks! *:-) --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: puzzling setup with ForeignKey
On 19 Feb, 13:15, a...@svilendobrev.com wrote: if u make it the same way as the other ticket_status... key, would it work? No, it won't. *:-( --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Autoloading float field from sqlite
I realize now that autoloading a float field in Sqlite returns a SLNumeric rather that Float. The schema is: sqlite .schema all_types CREATE TABLE all_types ( ... float FLOAT, ... PRIMARY KEY (id) ); is this a known issue? sandro *:-) --~--~-~--~~~---~--~~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] query doctest
Hi, in a doctest I have:: str(q) == str(query.filter(User.first_name == 'ed')) True that works but the following fails, (both where built starting from the same session.query(User) q == query.filter(User.first_name == 'ed') True in another place comparing str fails just because a join has ON join condition inverted (but semantically equivalent). What's the correct way to test if two queries are semantically equivalent? Thanks sandro *:-) --~--~-~--~~~---~--~~ 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] flush session.is_modified()
Hi, I have a code like this: if self.session.dirty: for dirty in self.session.dirty: if self.session.is_modified(dirty): return True if self.session.new: for obj in self.session.new: if self.session.is_modified(obj): return True I realized that if I have a session with autoflush=True, checking is_modified(dirty_obj), triggers a flush(), so that next loop on 'session.new' would never find anything. While I personally have non reason to keep autoflush=True, I didn't want to force this for everybody using my library (sqlkit). Is there a way to force is_modified (with collection) not to flush(), the same way as session.query can be issued without flushing? TIA sandro *:-) -- http://sqlkit.argolinux.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] Printing SQL statement
I noticed in message [1] a way of getting sql statement of meta.create_all(). It doesn't work for me: File /tmp/sa.py, line 11, in module gen = e.dialect.schemagenerator(e, proxy, None) File /misc/src/hg/py/sqlkit4/bin/../sqlalchemy/sql/compiler.py, line 777, in __init__ AttributeError: 'Engine' object has no attribute 'identifier_preparer' I there another way to get the SQL code? thanks *:-) [1] http://groups.google.it/group/sqlalchemy/browse_frm/thread/a03f49894b06a1a4/5bd8003c2f7980fc?hl=itlnk=gstq=create_all+print#5bd8003c2f7980fc --~--~-~--~~~---~--~~ 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] [Announce] sqlkit 0.8.3
I hope this list may be interested in this package based on sqlalchemy. Working with sqlalchemy has been a very nice experience, any day discovering some nice feature of sqlalchemy that just fitted my needs. I know I only used a subset of SA power but my intention is to add features as long as I learn and need them. Any feedback, comment, criticism, hint or patch is really appreciated. Note: I only tested it with PostgreSQL, sqlite, MySql, should someone test it with other backends I'd be very interested in having a feedback Thanks for SA and for the support that made it possible to get here sandro *:-) ANNOUNCE: sqlkit 0.8.3 November, 10 2008 I'm happy to announce release 0.8.3 of sqlkit package for python - the first public release. http://sqlkit.argolinux.org/ The package --- SQLkit PyGtk package provides Mask and Table widgets to edit database data. It's meant as a base for database desktop applications. The application --- It also provides 'sqledit' a PyGTK application based on sqlkit that can be used from command line to browse and edit data. The package has 2 very rich demo suites for sql widgets (the main one in sqlkit/demo/sql/demo.py) and for layout creation Main features of sqlkit: * editor of databases in 2 modes: table mask * based on sqlalchemy: can cope with many different databases * very powerfull filtering capabilities: - each field can be used to filter records - filter may span relationship - date filtering possible also on relative basis (good for saved queries) * completion on all text field and foreign keys * very easy way to draw a layout for mask views * completely effortless editing of relationships * very easy way to set defaults * possibility to display totals of numeric fields * any possible sql constraint can be attached to a Mask or a Table. It can be expressed a s a normal sqlalchemy query or with django-like syntax * sqledit: python script to edit db Sqlkit is based on: --- * python (= 2.4) * PyGtk * Sqlalchemy (= 0.5) * glade * dateutils Dowload more: --- * http://docs.argolinux.org/sqlkit/sqlkit/download.html * hg clone http://hg.argolinux.org/py/sqlkit * google group: http://groups.google.it/group/sqlkit/ * License: GNU GPL --~--~-~--~~~---~--~~ 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] Missing 'match' documentation?
Hi, I think I don't see documentation on the 'match' operator that works differently according to db backend. If I just missed it please point me to the right place, otherwise can you give me some more info? How can it be used with sqlite: can it work as ~ in postgres? If I try lo used it as in: session.query(mapper).filter(title_col.match('a')) I get back a: class 'sqlalchemy.exc.OperationalError': (OperationalError) unable to use function MATCH in the requested context u'SELECT movie.id AS movie_id, movie.title AS movie_title, movie.description AS movie_description, movie.year AS movie_year, movie.date_release AS movie_date_release, movie.director_id AS movie_director_id \nFROM movie \nWHERE movie.title MATCH ? ORDER BY director_id \n LIMIT 200 OFFSET 0' ['a'] TIA sandro *:-) --~--~-~--~~~---~--~~ 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] ClauseList with join?
Hi, I started using the .join() method on query and that' s really powerful, with reset_joinpoint and the list of attributes setting the path of relations. Now I'd like to being able to write join clause in advance with respect to the moment I have the the query available , in he same way I can write ClauseList in advance. Is there any way? Thanks sandro --~--~-~--~~~---~--~~ 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: commit vs flush
least this seems to me...) In the GUI I use as test, thoght objects are flushed but they come back unless I issue a session.commit(). Hmm. If by come back you mean they show back up in a separate session and still exist in the database, then it may be that you've forgotten to commit the transaction at all. If you turn off autocommit, transactions are never committed except by explicitly calling commit(). indeed that's the case. But if I commit(), any other object in the session get committed and I don't want this... thanks again sandro *:-) --~--~-~--~~~---~--~~ 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] commit vs flush
Hi, I'm trying to flush deletion of single objects w/o triggering a complete commit and even after reading the docs several time I think I have not got it right. In a little test I manage to do it correctly: I delete/ flush single objects and they are DELETEd from the table (at least this seems to me...) In the GUI I use as test, thoght objects are flushed but they come back unless I issue a session.commit(). At that point I realized that I didn't really understand what would be the difference between: flush() commit() I did understand that commit issues a flush... but then... what is a flush w/o a commit? I do see that after flushing session.dirty is empty and setting bind.echo = True shows: DELETE sqlkit.db.proxy.director_class object at 0x8bb260c 2008-09-08 00:24:16,882 INFO sqlalchemy.engine.base.Engine.0x...e0cc DELETE FROM director WHERE director.id = ? 2008-09-08 00:24:16,882 INFO sqlalchemy.engine.base.Engine.0x...e0cc [19] DIRTY IdentitySet([]), Nevertheless if I don't issue a session.commit() the objects I deleted come back. (Using sqlite for the test. session.autoflush = True, autocommit=False ) Thanks for any explanation sandro *:-) --~--~-~--~~~---~--~~ 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: session.dirty but not session.is_modified....
Thanks. In fact I use session.is_modified() but I thought it was just a workaround to cope with something I didnt' thoroughly understand... sandro *:-) --~--~-~--~~~---~--~~ 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: validation and old values
thanks sandro *:-) --~--~-~--~~~---~--~~ 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] session expire and discard
Hi, is there a way to say to a session to forget all the changes to an object without hitting the database. Expire or refresh do that but at the prize of a new select. Thanks --~--~-~--~~~---~--~~ 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] validation and old values
Hi, I'm adding validation to a (generic) gtk sql editor. The first thing I'd like to know is if I can reach the old values of an instance after I modified it (before committing). The reason is that I'd like to give the possibility to have new and old values in the validation of the record. thanks in advance sandro --~--~-~--~~~---~--~~ 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] PG: INET type support
PostgreSQL inet type seems not to be a supported type at the moment. Are there plans to add it in SA? I just added it in postgresql.py 'inet': PGInet, class PGInet(sqltypes.INET): def get_col_spec(self): return INET I'm unsure what sould be returned by get_dbapi_type class Inet(TypeEngine): Implements a type for inet objects def get_dbapi_type(self, dbapi): return dbapi.??? class INET(Inet): pass What else should be done, which is the best way to go not to have to patch after any svn update? A laste question. How (if at all) can I use get_dbapi_type to know the type of a returned data after autoloading a Table but *before* issueing a query? (to know wich widget should handle it). TIA sandro *:-) -- Sandro Dentella *:-) http://www.tksql.orgTkSQL Home page - My GPL 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 -~--~~~~--~~--~--~---