[sqlalchemy] Error with SqlSoup and Firebird engine
Hi, I'm trying to use SqlSoup with firebird backed. My environment is: python 2.6, sqlalchemy 0.6.3 all in virtualenv. The firebird version is 2.1 I do all steps to do a simple test: db = SqlSoup('firebird://SYSDBA:master...@127.0.0.1/home/maxi/ databases/test.fdb') people = db.people.all() for p in people: print p.name When SqlSoup tries to execute: people = db.people.all() I get the next Traceback Traceback (most recent call last): File pru.py, line 24, in module people = db.people.all() File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/ext/sqlsoup.py, line 550, in __getattr__ return self.entity(attr) File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/ext/sqlsoup.py, line 539, in entity table = Table(attr, self._metadata, autoload=True, autoload_with=self.bind, schema=schema or self.schema) File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/schema.py, line 209, in __new__ table._init(name, metadata, *args, **kw) File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/schema.py, line 257, in _init include_columns=include_columns) File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/engine/base.py, line 1772, in reflecttable conn = self.contextual_connect() File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/engine/base.py, line 1742, in contextual_connect self.pool.connect(), File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/pool.py, line 158, in connect return _ConnectionFairy(self).checkout() File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/pool.py, line 329, in __init__ rec = self._connection_record = pool.get() File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/pool.py, line 177, in get return self.do_get() File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/pool.py, line 692, in do_get con = self.create_connection() File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/pool.py, line 138, in create_connection return _ConnectionRecord(self) File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/pool.py, line 213, in __init__ self.connection = self.__connect() File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/pool.py, line 279, in __connect connection = self.__pool._creator() File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/engine/strategies.py, line 76, in connect return dialect.connect(*cargs, **cparams) File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ sqlalchemy/engine/default.py, line 238, in connect return self.dbapi.connect(*cargs, **cparams) File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ kinterbasdb/__init__.py, line 478, in connect return Connection(*args, **keywords_args) File /home/maxi/.virtualenvs/miskred/lib/python2.6/site-packages/ kinterbasdb/__init__.py, line 641, in __init__ b.dsn, b.dpb, b.dialect, timeout sqlalchemy.exc.OperationalError: (OperationalError) (-902, 'isc_attach_database: \n I/O error for file home/maxi/databases/ test.fdb\n Error while trying to open file\n No such file or directory') None None What is wrong here? Thanks in advance. Maxi. -- 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 base and Adjacency List Relationships
Hi, I´ve just using sqlalchemy 0.5.1 with python 2.6 and turbogers, but I found a little problem trying to configurate adjacency relationship with declarative base. My object class is something like this: class QueryGroup(DeclarativeBase): __tablename__ = 'queries_group' qry_grp_id = Column(Smallinteger, primary_key=True) qry_grp_desc = Column(Unicode(20), nullable=False) parent_id = relation('QueryGroup', backref='parent') When I try to generate my tables, I get an error like this: sqlalchemy.exc.ArgumentError: Could not determine join condition between parent/ child tables on relation QueryGroup.parent_id. Specify a 'primaryjoin' expressi on. If this is a many-to-many relation, 'secondaryjoin' is needed as well. How can I specify the correct statement? Using traditional mapper approach, I can do: queries_group = Table(...) mapper(QueryGroup, queries_group, properties={ 'children': relation(QueryGroup, cascade=all, backref=backref(parent, remote_side= [queries_group.c.qry_grp_id])) } ) Can I do the same using declarative style? How? Thanks in advance. --- Maxi. --~--~-~--~~~---~--~~ 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] getting columns name from query result
Hi, Are there any approach to get columns names from query result ? I'm executing a dynamic sql statemet using text function and execute. s = 'select * from foo where foo.name like = :name' txt = text(s, bind=database.metadata.bind) p = {'name':u'some name'} result = txt.execute(p).fetchall() Now, I need something like... result.get_columns_names() 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Many to many relationship problem
Hi, I've a problem to do a many to many relationship mapper declaration. I will try to explain this with an example: person_table(per_id, name, ...) per_per_table(id, per_orig_id, per_dest_id) per_orig_id = foreign key, reference to person_table.per_id per_dest_id = foreign key, reference to person_table.per_id How map this? I do... mapper(Person, person_table, properties={'dest': relation(Person, secondary=per_per_table)} I want to do: per = Person() per_dest = Person() per.dest.append(per_dest) But, sqlalchmey can't determinate how do the relationship: Error determining primary and/or secondary join for relationship How can I solve this? Thanks in advance. M. --~--~-~--~~~---~--~~ 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] Using substring function
Hi, I need to use substring function into sql statement. For it, I define the next sql: _sql = select([func.substring(planilladet.c.msg_debug, 1, 40).label('msg_debug'), func.sum(planilladet.c.cant).label('cant'), func.sum(planilladet.c.cant * planilladet.c.importe).label('importe')], \ from_obj=[planilladet.join(planilla)], group_by=[1]) When I execute that sql, this error message appear: (ProgrammingError) (-104, 'isc_dsql_prepare: \n Dynamic SQL Error\n SQL error code = -104\n Token unknown - line 1, column 39\n ,') 'SELECT substring(planilladet.msg_debug, ?, ?) AS msg_debug, sum(planilladet.cant) AS cant, sum(planilladet.cant * planilladet.importe) AS importe \nFROM planilladet JOIN planilla ON planilla.plan_id = planilladet.plan_id \nWHERE planilla.conv_id = ? AND planilla.fec_imput = ? GROUP BY 1' [1, 40, 1, datetime.date(2008, 2, 1)] What can be the problem here? 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] Re: Using substring function
(ProgrammingError) (-104, 'isc_dsql_prepare: \n Dynamic SQL Error\n SQL error code = -104\n Token unknown - line 1, column 39\n ,') 'SELECT substring(planilladet.msg_debug, ?, ?) AS msg_debug, sum(planilladet.cant) AS cant, sum(planilladet.cant * planilladet.importe) AS importe \nFROM planilladet JOIN planilla ON planilla.plan_id = planilladet.plan_id \nWHERE planilla.conv_id = ? AND planilla.fec_imput = ? GROUP BY 1' [1, 40, 1, datetime.date(2008, 2, 1)] What can be the problem here? Thanks in advance. Oopss, sorry, I respond to myself. The problem is with substring function, in SQL (I'm using Firebird 2.x) substring funcition sintax is: SUBSTRING(planilladet.msg_debug 1 FROM 40) How can do it in sqlalchemy ? (I use sqlalchemy 0.3.11) --~--~-~--~~~---~--~~ 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: Update master-detail problem
is the SQL emitted ? No, It isn't. By example, if I modify master record data usr1.name = new name and modify any addresses object (like first example) the sql statement (UPDATE) is generated for users table but not for addresses table. is it possible your session is in an open transaction and you need to commit() ? No. also, if the email_address attribute of addr is already [EMAIL PROTECTED], no SQL will be emitted for that either since nothing has changed. Yes, I know. Maybe I don't be clear in my example, but addr.email_address have not assigned the same value. The idea is what this attribute change, but not update is generated. BTW, I do a simple (and quickly) test using large_collection.py example. This use sqlite engine and in this case all apperar work fine. (Repeat, It was a quickly test). Perhaps, it's a firebird engine problem. --~--~-~--~~~---~--~~ 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 0.4.3 Released
Great Job !!! How can I upgrade from 0.4.2p3 ? (Or I have to uninstall all previous version?) Regards. --~--~-~--~~~---~--~~ 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] Executing sql text from session
Hi, I'm reading sqlalchemy 0.4 documentation about how execute a sql text from session obejct. In this example, Session = sessionmaker(bind=engine, transactional=True) sess = Session() result = sess.execute(select * from table where id=:id, {'id':7}) It's only present in 0.4.x versions ? How can do it in 0.3.x versions? TIA. --~--~-~--~~~---~--~~ 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: Refresh problem in orm
Thanks for your replay, The easiest in this case is to use query.populate_existing(): sess.query(Person).populate_existing().filter_by().all() however, this method is only available in 0.4. How work this ? This method - populate_existing() - re-read from database ? in 0.3, several options: 1. clear the session, then query: sess.clear() sess.query(Person) I've many problems when I use session.clear() method, see: http://groups.google.be/group/sqlalchemy/browse_thread/thread/d3d077c599d4fe22#cc03342771973db0 Anyway, I test to use session.clear() before query and this work fine. --~--~-~--~~~---~--~~ 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: Search in object list by field value
Thanks Simon, I was doing of that manner. Now, is advisable implement my own custom collection ? (One what implement a locate method for example) I was reading Custom Collection Implementations on sqlalchemy doc, but I'am not very clear over how implement this. Any help with this? Regards. --~--~-~--~~~---~--~~ 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] Object list synchronization
Hi, I will try to expose my scenario: I'am using sqlalchemy 0.3.10, Firebird 2.0.x and PyGtk for build a desktop application in Windows XP. I've a window form which contains a gtk TreeView (and many other widgets). This is used for data entry in a master/detail structure. Then, I've a mapper like this: mapper(Detail, detail_table) mapper(Master, master_table, properties={ 'items': relation(Detail, cascade=all, delete-orphan) } ) Now, I input data in my form and items detail in my TreeView list. This form have two options to access, insert and edit. When I use this for insert I haven't problem here, because are all new objects (which don't exists in database). But, how can manage this for edit ? How can I synch my Detail list object (Master.items) with my TreeView object? When I access by edit, I must do insert or delete on my TreeView. Here, a little pseudocode like example: # for insert: master = Master() # assign some data to master, reading from my form widgets # load detail for row in my_gtk_tree_list: det = Detail() # assign some data to det master.items.append(det) # # for edit: I can delete items on my tree view, and I must synchronize this with my Master.items list How can do it? Because, if I do master.items = [], before re-load from tree list and I populate all details all time, For instance, # load detail master.items = [] for row in my_gtk_tree_list: det = Detail() # assign some data to det from row master.items.append(det) But I get this exception when I do session.save. ConcurrentModificationError: Updated rowcount 1 does not match number of objects updated 6 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] Re: ConcurrentModificationError without concurrent modification?
One more thing, I remove the many to many mapper (for ConvPre class and the associated mapper) and: - This work fine on sa 0.4.x - This don't work on sa 0.3.10 Are there any changes relative a this problem in 0.4.x versions ? --~--~-~--~~~---~--~~ 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] [REPEAT] ConcurrentModificationError without concurrent modification?
Hi, I've a problem like this: http://groups.google.be/group/sqlalchemy/browse_thread/thread/e3ff5bd168f5045a Now, I'am using sqa 0.3.10, and a very complex mapper estructure. orm.mapper(PrestacionGrupo, prestacion_grupo) orm.mapper(Prestacion, prestacion, properties={ 'grupo': relation(PrestacionGrupo), 'anexos': relation(Prestacion, primaryjoin=prestacion.c.parent_id==prestacion.c.pre_id) } ) orm.mapper(ConvenioEstado, convenio_estado) orm.mapper(Convenio, convenio, properties={ 'efector': relation(Efector, primaryjoin=Efector.c.efe_id==convenio.c.efe_id), 'estado': relation(ConvenioEstado, primaryjoin=ConvenioEstado.c.conv_est_id==convenio.c.conv_est_id, lazy=False), 'prestaciones': relation(Prestacion, secondary=convenio_prestacion, lazy=True) }, extension=ConvenioExtension() ) I create an instance of Convenio [ convenio = Convenio() ] I do, convenio.prestaciones.delete(obj_instance) for delete a object from prestaciones list. Now, if I delete one object only, this work fine, but if I delete many (i.e: two obj) that error ocurr when I call to session.flush([convenio]). File C:\Python\Python25\Lib\site-packages\sqlalchemy-0.3.10-py2.5.egg \sqlalchemy\orm\dependency.py, line 372, in process_dependencies raise exceptions.ConcurrentModificationError(Deleted rowcount %d does not match number of objects deleted %d % (result.rowcount, len(secondary_delete))) ConcurrentModificationError: Deleted rowcount 1 does not match number of objects deleted 2 Why with deleting one object from list work fine, but this fail if I delete two or more?. How I can solve this? 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] Re: [REPEAT] ConcurrentModificationError without concurrent modification?
the error is specifically about a many to many table where it expects to delete two rows but only one matches the criteria. If you are using more than one session, or removing rows from a many to many table using SQL statements, this error can occur. Sorry, I'am a little confuse abut it. (I have only one session) I've the next table schema: convenio(conv_id) --- conv_pre(conv_pre_id, conv_id, pre_id) --- prestacion(pre_id)(convenio many to many with prestacion across conv_pre) conv_pre has a unique index on (conv_id, pre_id) but conv_pre_id is the primary key Then, for simplify, I've this mapper: mapper(Convenio, convenio, properties={ 'prestaciones': relation(Prestacion, secondary=convenio_prestacion, lazy=True) } ) Now, I want to do: pre = session.query(Prestacion).get(123) conv = session.query(Convenio).get(1) conv.prestaciones.delete(pre) And this, must delete one record from conv_pre table where conv_id = 1 and pre_id = 123 (pre.pre_id) I don't understand why this error ocurr. You can explain me, please? Thanks so much for your help. Another condition, also mentioned in the original thread, that can exactly cause this issue is if you set up two many-to-many relations against the same table, instead of using a backref, like: mapper(A, a, properties={ 'bs':relation(B, secondary=a_to_b) }) mapper(B, b, properties={ 'as':relation(A, secondary=a_to_b) }) The correct way to do the above is: mapper(A, a, properties={ 'bs':relation(B, secondary=a_to_b, backref='bs') }) mapper(B, b) hope this helps --~--~-~--~~~---~--~~ 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: [REPEAT] ConcurrentModificationError without concurrent modification?
do you have anything else mapped to the conv_pre table ? it should *only* be mentioned in one place in your mapping setup. I only have something like this: class ConvPre(DBObject): pass mapper(ConvPre, conv_pre) --~--~-~--~~~---~--~~ 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: [REPEAT] ConcurrentModificationError without concurrent modification?
OK, then you *cannot* use conv_pre as the secondary argument in another relation(). You need to use an association: If I remove ConvPre class and conv_pre mapper too. This problem is solved ? I don't need this class and mapper really. BTW, I will take a look to associationproxy, this look like a great solution. Regards. --~--~-~--~~~---~--~~ 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] object has no attribute '_sa_session_id' error on session.clear()
Hi, I've an error when I try to execute a clear() method from session object. Traceback (most recent call last): File V:\nacer\bin\gui\planilla.py, line 280, in on_btn_apply_clicked self._savePlanilla() File V:\nacer\bin\gui\planilla.py, line 200, in _savePlanilla PlanillaService().save(planilla) File V:\nacer\bin\common\services.py, line 16, in save session.clear() File c:\programs\python25\lib\site-packages\sqlalchemy-0.4.2p3- py2.5.egg\sqlalchemy\orm\session.py, line 577, in clear self._unattach(instance) File c:\programs\python25\lib\site-packages\sqlalchemy-0.4.2p3- py2.5.egg\sqlalchemy\orm\session.py, line 1039, in _unattach if instance._sa_session_id == self.hash_key: AttributeError: 'PlanillaDet' object has no attribute '_sa_session_id' I do, session.save_or_update(dataset) session.flush([dataset]) session.clear() Why this error ocurr? TIA. --~--~-~--~~~---~--~~ 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] problems with filter_by()
Hi, I recently upgrade from sqlalchemy 0.3.10 to 0.4.2p3. I have a method like this: def getPlanillaDet(self, plan_id): return session.query(PlanillaDet).filter_by(Planilladet.c.plan_id==plan_id).all() Now, after update, when I try to execute this method, I get an exception with the next message: File V:\nacer\bin\common\services.py, line 192, in get return session.query(PlanillaDet).filter_by(Planilladet.c.plan_id==plan_id).all() TypeError: filter_by() takes exactly 1 argument (2 given) What is the problem here ? 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] Re: problems with filter_by()
Thaks for your help. Can you post an example over how to use filter and filter_by in new sqlalchemy versions? Is your recommendation included in 0.3 to 0.4 migration guide? Why this change? Regards. --~--~-~--~~~---~--~~ 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] MapperExtension upgrade
Hi, In new sqlalchemy version (0.4), the MapperExtension must return EXT_CONTINUE for each method. Now, all methods must return this const? For instance, I've the next extension for my mapper: class ConvenioExtension(MapperExtension): def create_instance(self, mapper, selectcontext, row, class_): return Convenio() Because I need create my owner class ever. Then, I have to return EXT_CONTINUE here? How? TIA. --~--~-~--~~~---~--~~ 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] InvalidRequestError when I try to save object
Hi, Follwing with my 0.3 to 0.4 upgrade, now I get the next problem... When I try to save an object across my session, I get an InvalidRequestError exception with the message: File c:\programs\python25\lib\site-packages\sqlalchemy-0.4.2p3- py2.5.egg\sqlalchemy\orm\session.py, line 988, in _save_impl raise exceptions.InvalidRequestError(Instance '%s' is already persistent % mapperutil.instance_str(instance)) InvalidRequestError: Instance '[EMAIL PROTECTED]' is already persistent Why with 0.3 I had not this error? Any help? --~--~-~--~~~---~--~~ 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: InvalidRequestError when I try to save object
I must use save_update alone or save_update + flush ? --~--~-~--~~~---~--~~ 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: InvalidRequestError when I try to save object
But, is my design mistake ? I must use ever save_or_update() function? In my case, I have two process working over the same class of bussines object. I do a query, which return me an object list and I call to other function which pass one parameter (id) and this function do other query over the same class. i.e.: Table - Person person_list = my_service.get_people() for p in person_list: process_person(p.id) def process_person(id): person = my_service.get_person() do something with person session.save(person) # here, raise exception: InvalidRequestError: Instance... already persistent session.flush([person]) Now, I chage session.save_or_update(person), and this work fine. --~--~-~--~~~---~--~~ 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] SqlAlchemy 0.4 and py2exe. Problem solved?
Is solved the problem involved in py2exe and sqlalchemy 0.3 ? Can I use py2exe without problem with loggin module? --~--~-~--~~~---~--~~ 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] Virtual column-attribute
Hi, I hope sombody can help me whit this. I've the next table, for instance: customer = Table('customer', metadata, Column('id', Integer, primery_key=True), Column('name', String(50), nullable=False) ) andthe class class Customer(object): pass and.. the mapper mapper(Customer, customer) Now, I want add a virtual attribute to my class which is not part of my table, for example class Customer(object) def __init__(self) self.selected = False Then, I do a simple query: cust = session.query(Customer).get(1) but, when I want use cust.selected = True An exception ocurr, the cust object have not 'selected' attribute How can solve this? Is possible do it? Than 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 -~--~~~~--~~--~--~---