[sqlalchemy] SQLAlchemy - Problem with an association table and dates in primary join

2010-03-04 Thread Richard Lopes
Hi, I am working on defining my mapping with SQLAlchemy and I am pretty much done except one thing. I have a 'resource' object and an association table 'relation' with several properties and a relationship between 2 resources. What I have been trying to do almost successfully so far, is to

Re: [sqlalchemy] [PROPOSE] Integrate migration support in SQLAlchemy

2010-03-04 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: I'm pretty much -1 on this since I think migrations need to have absolute flexibility - the listener system within create_all() is not at all designed to be used to that degree. Another solution is to add a completely

[sqlalchemy] case sensitive Unicode and String columns

2010-03-04 Thread Chris Withers
Hi All, I'm looking to create a model with a unicode or string column type that is case sensitive. I'm looking to do this in the model in such a way that the code in the model doesn't know or care about what backend database is used, but that barfs if it's ever used with a backend that

Re: [sqlalchemy] bug in sqllite dialect?

2010-03-04 Thread Chris Withers
Hi Michael, Thanks for this, I thought I asked this separately but I can't find the mail now... How would you recommend I work this now in 0.5.8 until I can move to 0.6.0? (which will take some months :-S) I seem to remember you suggesting a custom type. Where can I find examples of those

Re: [sqlalchemy] case sensitive Unicode and String columns

2010-03-04 Thread Daniel Robbins
On Thu, Mar 4, 2010 at 11:34 AM, Chris Withers ch...@simplistix.co.uk wrote: Hi All, I'm looking to create a model with a unicode or string column type that is case sensitive. I'm looking to do this in the model in such a way that the code in the model doesn't know or care about what

[sqlalchemy] preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Kent
If I use session.refresh(obj) to re-load an obj that has a one-to-many relational property, the objects in the list are *replaced* instead of *refreshed* if they already exist. Suppose department has a list of employees: suppose dept.employees = [ emp1, emp2 ] session.refresh(dept) the

Re: [sqlalchemy] [PROPOSE] Integrate migration support in SQLAlchemy

2010-03-04 Thread Michael Bayer
Manlio Perillo wrote: -BEGIN PGP SIGNED MESSAGE- But it is a simple metadata. It can also be stored in the `info` dictionary (and this is what I plan to do if I have to write the support by myself). yeah I dont really want any migration aware in core. I don't consider create_all()

[sqlalchemy] insert defaults

2010-03-04 Thread patrick
Hey, I'm trying to create dynamic defaults for columns ala http:// www.sqlalchemy.org/docs/metadata.html#context-sensitive-default-functions. MySQL has COMPRESS and UNCOMPRESS functions that I'm trying to leverage. I don't want to compress with python's zlib because I have legacy tables that

Re: [sqlalchemy] preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Michael Bayer
Kent wrote: If I use session.refresh(obj) to re-load an obj that has a one-to-many relational property, the objects in the list are *replaced* instead of *refreshed* if they already exist. Suppose department has a list of employees: suppose dept.employees = [ emp1, emp2 ]

Re: [sqlalchemy] case sensitive Unicode and String columns

2010-03-04 Thread Michael Bayer
Daniel Robbins wrote: On Thu, Mar 4, 2010 at 11:34 AM, Chris Withers ch...@simplistix.co.uk wrote: Hi All, I'm looking to create a model with a unicode or string column type that is case sensitive. I'm looking to do this in the model in such a way that the code in the model doesn't know

Re: [sqlalchemy] bug in sqllite dialect?

2010-03-04 Thread Michael Bayer
Chris Withers wrote: Hi Michael, Thanks for this, I thought I asked this separately but I can't find the mail now... How would you recommend I work this now in 0.5.8 until I can move to 0.6.0? (which will take some months :-S) I seem to remember you suggesting a custom type. Where can I

Re: [sqlalchemy] insert defaults

2010-03-04 Thread Michael Bayer
patrick wrote: Hey, I'm trying to create dynamic defaults for columns ala http:// www.sqlalchemy.org/docs/metadata.html#context-sensitive-default-functions. MySQL has COMPRESS and UNCOMPRESS functions that I'm trying to leverage. I don't want to compress with python's zlib because I have

[sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Kent
What's strange is that I can't recreate the problem on more simple stage. Every time I refresh() on the parent object, the list objects remain the same. In other words, *sometimes* it behaves as I hope it to (by apparently refreshing the list's objects) and *sometimes* if throws them out and

Re: [sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Michael Bayer
refresh doesn't remove any objects from the session so its a matter of what is present in the session, not marked as dirty, and strongly referenced on the outside. if you're using refresh you shouldn't care about how it gets data back into the collection. Kent wrote: What's strange is that I

[sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Kent
I agree I shouldn't care, so maybe there is another way to attack my problem. The reason I care is because I've extended the python object with some auxiliary information that I need. After the refresh() in this case, I still need access to that data that is tied to the object, but not present

Re: [sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Conor
Kent wrote: I agree I shouldn't care, so maybe there is another way to attack my problem. The reason I care is because I've extended the python object with some auxiliary information that I need. After the refresh() in this case, I still need access to that data that is tied to the object,

Re: [sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Conor
Conor wrote: Kent wrote: I agree I shouldn't care, so maybe there is another way to attack my problem. The reason I care is because I've extended the python object with some auxiliary information that I need. After the refresh() in this case, I still need access to that data that is

[sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Kent
Thanks... that is very helpful. I could keep references to these. If I choose the apparently lazier route and set weak_identity_map=False, then does any other action besides explicitly expunging free this memory, such as when the session goes out of scope, I assume? Or do I need to carefully

Re: [sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Michael Bayer
Kent wrote: Thanks... that is very helpful. I could keep references to these. If I choose the apparently lazier route and set weak_identity_map=False, then does any other action besides explicitly expunging free this memory, such as when the session goes out of scope, I assume? Or do I need

[sqlalchemy] Base class with primary key and sequence (Mix-in?)

2010-03-04 Thread Daniel Robbins
Hi All, I have created a base declarative object that has a pre-made primary key, so I don't have to add it to all my child tables: class ClassDefaults(DeclarativeMeta): def __init__(cls,classname, bases, dict_): dict_['id'] = Column(Integer, Sequence(id_seq,

[sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Kent
Ok, I wonder the reasons, but I trust your answer completely, so I won't disable it. Thanks for your help again. On Mar 4, 4:26 pm, Michael Bayer mike...@zzzcomputing.com wrote: Kent wrote: Thanks... that is very helpful.  I could keep references to these.  If I choose the apparently lazier

[sqlalchemy] Re: oracle insert problem

2010-03-04 Thread celord
Thanks a lot Michael, now it works! this is my final script, maybe it could help others: engine = create_engine('oracle://user:passw...@host:1521/dbname', echo=True) metadata = MetaData() pushmail_table = Table('pushmail', metadata, Column('telefono', String, primary_key=True),

[sqlalchemy] Primary key Mix-in not working with adjacency list

2010-03-04 Thread Daniel Robbins
Hi all, I tried to convert some existing code containing an adjacency list to mix-ins, and the mix-in version doesn't seem to be liked by SQLAlchemy 0.6_beta1: Original code that works: class ClassDefaults(DeclarativeMeta): def __init__(cls,classname, bases, dict_):

[sqlalchemy] Re: Base class with primary key and sequence (Mix-in?)

2010-03-04 Thread Daniel Robbins
On Thu, Mar 4, 2010 at 2:31 PM, Daniel Robbins drobb...@funtoo.org wrote: Hi All, I have created a base declarative object that has a pre-made primary key, so I don't have to add it to all my child tables: I figured out how to do this, using the following code: seqnum=0 def

[sqlalchemy] mapping to existing table with no primary key

2010-03-04 Thread robneville73
here's my issue...I have to map to an existing Oracle db table with 33million rows (yeah, I know). This table has no primary key and worse, nothing, and I mean nothing to uniquely identify a row (fabulous). as a backup, I realize that I can manually issue statements to this thing via SA, but I'd

Re: [sqlalchemy] mapping to existing table with no primary key

2010-03-04 Thread Michael Bayer
robneville73 wrote: here's my issue...I have to map to an existing Oracle db table with 33million rows (yeah, I know). This table has no primary key and worse, nothing, and I mean nothing to uniquely identify a row (fabulous). as a backup, I realize that I can manually issue statements to

[sqlalchemy] Re: mapping to existing table with no primary key

2010-03-04 Thread robneville73
Ahhh! Perhaps such a view coupled with an instead of trigger might work...I'd need to think about that, but that might work. Thanks Michael. On Mar 4, 6:12 pm, Michael Bayer mike...@zzzcomputing.com wrote: robneville73 wrote: here's my issue...I have to map to an existing Oracle db table with

[sqlalchemy] Re: [PROPOSE] Integrate migration support in SQLAlchemy

2010-03-04 Thread Lele Gaifax
Manlio Perillo manlio.peri...@gmail.com writes: Michael Bayer ha scritto: Similarly, the concept of a version as an integer number is not really flexible enough - The idea was to keep it simple. IMHE, there's no such a beast! I would like to investigate the creation of migration

[sqlalchemy] Can we use dates to define a relation with the mapper ?

2010-03-04 Thread Richard Lopes
Hi, I have this mapper defined: mapper(Resource, resource_table, properties = {'type' : relation(ResourceType,lazy = False), 'groups' : relation(Group, secondary = model.tables['resource_group'], backref = 'resources'), 'parent' : relation(Relation, uselist=False, primaryjoin

Re: [sqlalchemy] Can we use dates to define a relation with the mapper ?

2010-03-04 Thread Michael Trier
Hello, On Mar 4, 2010, at 10:50 PM, Richard Lopes wrote: Hi, I have this mapper defined: mapper(Resource, resource_table, properties = {'type' : relation(ResourceType,lazy = False), 'groups' : relation(Group, secondary = model.tables['resource_group'], backref = 'resources'),

Re: [sqlalchemy] Can we use dates to define a relation with the mapper ?

2010-03-04 Thread Richard Lopes
Hi, Thanks for the help but I think I got it working. Look here: http://stackoverflow.com/questions/2384438/sqlalchemy-can-we-use-date-comparison-in-relation-definition Cheers, Richard 2010/3/5 Michael Trier mtr...@gmail.com Hello, On Mar 4, 2010, at 10:50 PM, Richard Lopes wrote: Hi,