[sqlalchemy] [REPEAT] ConcurrentModificationError without concurrent modification?

2008-01-23 Thread maxi
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':

[sqlalchemy] Re: Two SqlAlchemy versions installed together

2008-01-23 Thread King Simon-NFHD78
If you're using easy_install to install them, you should be able to install them with the '-m' (--multiversion) switch. See: http://peak.telecommunity.com/DevCenter/EasyInstall#command-line-options Choosing the version you want to use in your application is then done like this: import

[sqlalchemy] Re: [REPEAT] ConcurrentModificationError without concurrent modification?

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 8:01 AM, maxi wrote: 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

[sqlalchemy] Can't figure out the joins across many tables with select_from()

2008-01-23 Thread Alexandre Conrad
Hello, still working intensivly with joined table inheritance. I have troubles making a long join across many tables. I need to query players from player_table where on the other end, slots_hot.id == 'foo': player_table = Table('players', meta, Column('id', Integer, primary_key=True),

[sqlalchemy] Improve code

2008-01-23 Thread VitaminJ
Hi, I have an existing piece of functionality but I am wondering if there are ways to improve the code. A short summary what I have. I modelled a person class which can have different roles, one being a student role, another one being an employee role, an alumni role and so on. Now I am trying

[sqlalchemy] Using MySQLdb type conversion as engine connection argument

2008-01-23 Thread Adrian
I am trying to change the default column type mapping in sqlalchemy. Analogous to the description in the MySQLdb User's Guide (http://mysql- python.sourceforge.net/MySQLdb.html) I tried the following. from MySQLdb.constants import FIELD_TYPE my_conv = { FIELD_TYPE.DECIMAL: float } ENGINE =

[sqlalchemy] Re: Can't figure out the joins across many tables with select_from()

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 10:25 AM, Alexandre Conrad wrote: Hello, still working intensivly with joined table inheritance. I have troubles making a long join across many tables. I need to query players from player_table where on the other end, slots_hot.id == 'foo': player_table =

[sqlalchemy] defining a StringSet type

2008-01-23 Thread Jonathon Anderson
I'm trying to use types.TypeDecorator to define a set of strings stored in the database as a csv list, where the empty set is stored as null. process_bind_param seems to work, as values set on the bound field seem to get entered correctly; but process_result_value never seems to be called when

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 11:09 AM, Jonathon Anderson wrote: I'm trying to use types.TypeDecorator to define a set of strings stored in the database as a csv list, where the empty set is stored as null. process_bind_param seems to work, as values set on the bound field seem to get entered

[sqlalchemy] Re: Using MySQLdb type conversion as engine connection argument

2008-01-23 Thread jason kirtland
Adrian wrote: I am trying to change the default column type mapping in sqlalchemy. Analogous to the description in the MySQLdb User's Guide (http://mysql- python.sourceforge.net/MySQLdb.html) I tried the following. from MySQLdb.constants import FIELD_TYPE my_conv = { FIELD_TYPE.DECIMAL:

[sqlalchemy] Re: [REPEAT] ConcurrentModificationError without concurrent modification?

2008-01-23 Thread maxi
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

[sqlalchemy] Re: [REPEAT] ConcurrentModificationError without concurrent modification?

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 2:15 PM, maxi wrote: 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)

[sqlalchemy] Re: Can't figure out the joins across many tables with select_from()

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 11:55 AM, Michael Bayer wrote: On Jan 23, 2008, at 10:25 AM, Alexandre Conrad wrote: model.Player.query.join(['site', 'playlists', 'hotlinks', 'hotslot']).filter(model.SlotHot.c.id=='foo').all() another thing im considering, along the lines of what I mentioned in

[sqlalchemy] Re: [REPEAT] ConcurrentModificationError without concurrent modification?

2008-01-23 Thread maxi
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

[sqlalchemy] Re: [REPEAT] ConcurrentModificationError without concurrent modification?

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 2:34 PM, maxi wrote: 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) OK, then you *cannot* use

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Jonathon Anderson
What do you mean by textual strings? Do you mean strings backed by a TEXT type, rather than a fixed-length string? Why won't that work? On Jan 23, 10:57 am, Michael Bayer [EMAIL PROTECTED] wrote: On Jan 23, 2008, at 11:09 AM, Jonathon Anderson wrote: I'm trying to use types.TypeDecorator

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 3:01 PM, Jonathon Anderson wrote: What do you mean by textual strings? Do you mean strings backed by a TEXT type, rather than a fixed-length string? Why won't that work? no, i mean: result = engine.execute(select * from table) will not work with any TypeEngine or

[sqlalchemy] Different results with select and object using outerjoin

2008-01-23 Thread MattQc
Hi, I have different outputs depending on using a select statement as oppose to an object mapped query. This is happening when I am using outer joins. Here is the trace of the select that gives me something: In 1: a = select([tblspotbandsol.c.spotbandsolid, tbllane.c.laneid],

[sqlalchemy] Re: [REPEAT] ConcurrentModificationError without concurrent modification?

2008-01-23 Thread maxi
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

[sqlalchemy] Re: Unique ID's

2008-01-23 Thread [EMAIL PROTECTED]
Thanks guys for your help I'm going to give Hermanns methods a go. Morgan Hermann Himmelbauer wrote: Am Montag, 21. Januar 2008 01:16 schrieb Morgan: Hi Guys, I have field that I want to put a unique identifier in. This unique Id i would like to be a composite key or simply a random

[sqlalchemy] odd question

2008-01-23 Thread Monty Taylor
This may or may not be elixir specific... If I have an auto-generated mapping table for a many-to-many relationship, is there a sensible way to add another column to it that's also has a foreign key relationship to a third table? Like, if I had this: Products id int name varchar

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Jonathon Anderson
Oh, no. I'm not doing any raw sql. I have (at a most basic level): things_table = Table(things, metadata, Column(id, types.Integer, primary_key=True), Column(values, StringSet, nullable=True), ) class Thing (object): pass Session.mapper(Thing, things_table) But when I do

[sqlalchemy] Re: Different results with select and object using outerjoin

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 3:28 PM, MattQc wrote: Object query returns an empty set: In 3: jLane = tblspotbandsol.outerjoin(tbllane, tbllane.c.laneid==tblspotbandsol.c.laneid) In 4: mapper(LaneClass,jLane) Out4: sqlalchemy.orm.mapper.Mapper object at 0xb36f382c In 5:

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 4:25 PM, Jonathon Anderson wrote: Oh, no. I'm not doing any raw sql. I have (at a most basic level): things_table = Table(things, metadata, Column(id, types.Integer, primary_key=True), Column(values, StringSet, nullable=True), ) class Thing (object):

[sqlalchemy] Re: odd question

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 4:24 PM, Monty Taylor wrote: This may or may not be elixir specific... If I have an auto-generated mapping table for a many-to-many relationship, is there a sensible way to add another column to it that's also has a foreign key relationship to a third table? Like,

[sqlalchemy] How to accomplish setup/run-app/teardown with mapped classes and sessions?

2008-01-23 Thread Kumar McMillan
Hello, I have not been able to figure this out from the docs. I would like to setup and teardown test data using mapped classes. The problem is that those same mapped classes need to be used by the application under test and in case there is an error, the teardown still needs to run so that

[sqlalchemy] Re: How to accomplish setup/run-app/teardown with mapped classes and sessions?

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 5:00 PM, Kumar McMillan wrote: Hello, I have not been able to figure this out from the docs. I would like to setup and teardown test data using mapped classes. The problem is that those same mapped classes need to be used by the application under test and in case there

[sqlalchemy] Re: How to accomplish setup/run-app/teardown with mapped classes and sessions?

2008-01-23 Thread Kumar McMillan
Hi On Jan 23, 2008 4:07 PM, Michael Bayer [EMAIL PROTECTED] wrote: your teardown code can't have any dependencies on the test code itself. So at the very least start the teardown phase with PrivateSession.close() so that you start fresh. I tried adding that to the teardown code but then

[sqlalchemy] Re: How to accomplish setup/run-app/teardown with mapped classes and sessions?

2008-01-23 Thread jason kirtland
Kumar McMillan wrote: Hello, I have not been able to figure this out from the docs. I would like to setup and teardown test data using mapped classes. The problem is that those same mapped classes need to be used by the application under test and in case there is an error, the teardown

[sqlalchemy] Re: How to accomplish setup/run-app/teardown with mapped classes and sessions?

2008-01-23 Thread Kumar McMillan
On Jan 23, 2008 4:36 PM, Kumar McMillan [EMAIL PROTECTED] wrote: ...but it still fails with the same error, Deleted rowcount 0 does not match number of objects deleted 1. What am I missing? I don't understand how the teardown code is dependent on the app code if it is using a different

[sqlalchemy] Asynchronous SQLAlchemy

2008-01-23 Thread Mike Lewis
Hi All, I'm starting a new project that will probably be using Twisted, but I want to use SQLAlchemy as well. I saw a couple of old posts about Asynchronous SQLAlchemy and two different implementations, but neither sAsync nor nadbapi seem to be maintained (or at least have new versions posted),

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Jonathon Anderson
So, in constructing my test case, I figured out what was going on. (I'm sure this is often the case.) http://pastebin.com/m612561a6 The problem is that process_result_value is only called when actually loading values from the database, and since a session maintains an object cache for object

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 10:16 PM, Jonathon Anderson wrote: So, in constructing my test case, I figured out what was going on. (I'm sure this is often the case.) http://pastebin.com/m612561a6 The problem is that process_result_value is only called when actually loading values from the

[sqlalchemy] Re: Problem with session and instance

2008-01-23 Thread Alex Turner
Thanks for the info - what is the current version? Alex On Jan 22, 2008 2:36 PM, Michael Bayer [EMAIL PROTECTED] wrote: One thing I can see is that you're using an older version of SA, since that error message has been changed (either 0.4.0 or an old 0.3 version). It means that you cannot

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Jonathon Anderson
I understand that solution. I did say without a python property. But if that's the only real way to do it, so be it. Maybe I was just looking for an excuse to learn how to define a custom type. ;) ~jon On Jan 23, 9:56 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jan 23, 2008, at 10:16 PM,

[sqlalchemy] Re: How to accomplish setup/run-app/teardown with mapped classes and sessions?

2008-01-23 Thread svilen
apart of all runtime issues u've hit - session etc - on declaration level u'll may do these: - destroy all your refs to the mappers/tables etc - sqlalchemy.orm.clearmappes() - yourmetadata.drop_all() - yourengine.dispose() - destroy refs to yourmetadata/yourengine