[sqlalchemy] Re: mappers for having problems with associations and flushing
here are my mappers in case that helps, maybe I don't understand the cascading properly? # relations for the bookings mapper( Booking, booking_table, properties={ 'client': relation( Client ), 'institution': relation( Institution, ), 'category': relation( Category ), 'staff_associations': relation(BookingStaffAssoc, lazy=False, cascade='all, delete-orphan', order_by=booking_staff_table.c.ordering ) }) # Association mapper, this is the important part! mapper( BookingStaffAssoc, booking_staff_table, primary_key=[ booking_staff_table.c.booking_id, booking_staff_table.c.staff_id], properties={ 'booking' : relation(Booking, lazy=False, cascade='all, delete-orphan' ), 'staff': relation(Staff, lazy=False, cascade='all, delete-orphan') }) 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] Extension proposal
Hi, I have a utility function that I keep using again and again in my web apps. It takes a nested hash/list structure, something like: data = \ { *'id'*: 123, *'name'*: *'Example customer'*, *'contacts'*: [ {*'id'*:12, name=*'Alice'*} {*'id'*:23, name=*'Bob'*} ] } And it takes an SQLAlchemy object. It updates the object based on the hash/list, in a deep way, in that it goes down relationships. There's an old version of my code here: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/ProcHash Anyway, I keep using this, so can it be included as an SQLAlchemy extension? If it's accepted, I will do the work to create unit tests for it. Paul --~--~-~--~~~---~--~~ 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] Mapper Issue Upgrading to 0.4.5
Hey All, I was upgrading our app from 0.4.1 to 0.4.5 and this code broke: pg_user = Table('pg_user', metadata, Column('usesysid', Integer, primary_key=True), Column('usename', Unicode(), unique=True)) pg_group = Table('pg_group', metadata, Column('grosysid', Integer, primary_key=True), Column('groname', Unicode(), unique=True), Column('grolist', PGArray(unicode))) mapper(PGUser, pg_user, properties={ 'groups': relation(PGGroup, viewonly=True, primaryjoin=pg_user.c.usesysid==func.any(pg_group.c.grolist), foreign_keys=[pg_group.c.grolist])}) Specify the foreign_keys argument to indicate which columns on the relation are foreign. % (self.primaryjoin, self)) ArgumentError: Could not determine relation direction for primaryjoin condition 'pg_user.usesysid = any(pg_group.grolist)', on relation PGUser.groups (PGGroup). Specify the foreign_keys argument to indicate which columns on the relation are foreign. I found this post(1) so I tried upgrading to SVN, but I still got the error. Does it have to do anything with the any() function and the PGArray column type? Koen (1) http://groups.google.com/group/sqlalchemy/browse_thread/thread/f8e5b5fa07ed9ab9/749beae25624c2f8?lnk=gstq=foreign_keys#749beae25624c2f8 --~--~-~--~~~---~--~~ 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: Extension proposal
just two seconds ago someone asked about sticking a JSON plugin in SQLAlchemy (this looks essentially like JSON to me).is the extension proposal something that builds in using MapperExtension ? it seems like people are just looking for json-like functions for things (which is handy, though not an SA-core kind of feature). On Apr 14, 2008, at 6:49 AM, Paul Johnston wrote: Hi, I have a utility function that I keep using again and again in my web apps. It takes a nested hash/list structure, something like: data = \ { 'id': 123, 'name': 'Example customer', 'contacts': [ {'id':12, name='Alice'} {'id':23, name='Bob'} ] } And it takes an SQLAlchemy object. It updates the object based on the hash/list, in a deep way, in that it goes down relationships. There's an old version of my code here: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/ProcHash Anyway, I keep using this, so can it be included as an SQLAlchemy extension? If it's accepted, I will do the work to create unit tests for it. Paul --~--~-~--~~~---~--~~ 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: Mapper Issue Upgrading to 0.4.5
On Apr 14, 2008, at 7:44 AM, Koen Bok wrote: Hey All, I was upgrading our app from 0.4.1 to 0.4.5 and this code broke: pg_user = Table('pg_user', metadata, Column('usesysid', Integer, primary_key=True), Column('usename', Unicode(), unique=True)) pg_group = Table('pg_group', metadata, Column('grosysid', Integer, primary_key=True), Column('groname', Unicode(), unique=True), Column('grolist', PGArray(unicode))) mapper(PGUser, pg_user, properties={ 'groups': relation(PGGroup, viewonly=True, primaryjoin=pg_user.c.usesysid==func.any(pg_group.c.grolist), foreign_keys=[pg_group.c.grolist])}) Specify the foreign_keys argument to indicate which columns on the relation are foreign. % (self.primaryjoin, self)) ArgumentError: Could not determine relation direction for primaryjoin condition 'pg_user.usesysid = any(pg_group.grolist)', on relation PGUser.groups (PGGroup). Specify the foreign_keys argument to indicate which columns on the relation are foreign. I found this post(1) so I tried upgrading to SVN, but I still got the error. Does it have to do anything with the any() function and the PGArray column type? nah I'd have to fix that for you. We have a long standing trac ticket for supporting functions/CAST within primaryjoin conditions, which don't really work, so again im completely surprised that relation worked for you. Use a plain descriptor perhaps ? (though ill try to see if it can be made to work again) --~--~-~--~~~---~--~~ 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: Extension proposal
Hi, In my case, the data is coming from FormEncode. I guess it could come from JSON, but that would be JSON client to server, which is not the usual way round. The proposal is for a standalone function, I'm thinking you'd do something like: from sqlalchemy.ext.proc_hash import proc_hash ... proc_hash(myobj, mydata) As this is just plumbing python data structures into database objects, I think it's fitting to the SA-core goals. Paul On Mon, Apr 14, 2008 at 3:00 PM, Michael Bayer [EMAIL PROTECTED] wrote: just two seconds ago someone asked about sticking a JSON plugin in SQLAlchemy (this looks essentially like JSON to me).is the extension proposal something that builds in using MapperExtension ? it seems like people are just looking for json-like functions for things (which is handy, though not an SA-core kind of feature). --~--~-~--~~~---~--~~ 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: Extension proposal
On Apr 14, 2008, at 10:11 AM, Paul Johnston wrote: Hi, In my case, the data is coming from FormEncode. I guess it could come from JSON, but that would be JSON client to server, which is not the usual way round. JSON is just an object encoding, in my mind it has no implications regarding clients/servers. The proposal is for a standalone function, I'm thinking you'd do something like: from sqlalchemy.ext.proc_hash import proc_hash ... proc_hash(myobj, mydata) As this is just plumbing python data structures into database objects, I think it's fitting to the SA-core goals. the function so far seems pretty use-case specific. (only works in one direction, is hardcoded to the obj.mapper convention, sort of looks like JSON but isn't, etc.) Even if it were JSON I dont think thats an SA core feature. --~--~-~--~~~---~--~~ 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: Mapper Issue Upgrading to 0.4.5
On Apr 14, 2008, at 7:44 AM, Koen Bok wrote: Hey All, I was upgrading our app from 0.4.1 to 0.4.5 and this code broke: pg_user = Table('pg_user', metadata, Column('usesysid', Integer, primary_key=True), Column('usename', Unicode(), unique=True)) pg_group = Table('pg_group', metadata, Column('grosysid', Integer, primary_key=True), Column('groname', Unicode(), unique=True), Column('grolist', PGArray(unicode))) mapper(PGUser, pg_user, properties={ 'groups': relation(PGGroup, viewonly=True, primaryjoin=pg_user.c.usesysid==func.any(pg_group.c.grolist), foreign_keys=[pg_group.c.grolist])}) use the trunk and say: mapper(PGUser, pg_user, properties={ 'groups': relation(PGGroup, viewonly=True, primaryjoin=pg_user.c.usesysid==func.any(pg_group.c.grolist), foreign_keys=[pg_group.c.grolist], _local_remote_pairs=[pg_user.c.usesysid, pg_group.c.grolist] )}) this doesn't yet handle the full blown functions/casts in primaryjoin conditions ticket but its part of the way there. --~--~-~--~~~---~--~~ 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 in virtualenv Instructions
Hello, Below you can find instructions on how to setup sqlalchemy in virtual environment. http://lucasmanual.com/mywiki/TurboGears#head-36fb4094da01b8c28e8bdca803c0f05774eb13b8 Enjoy, Lucas -- Automotive Recall Database. Cars, Trucks, etc. http://www.lucasmanual.com/recall/ Install Broadcom wireless card on Linux: http://lucasmanual.com/mywiki/bcm43xx --~--~-~--~~~---~--~~ 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 in virtualenv Instructions
Lukasz Szybalski wrote: Hello, Below you can find instructions on how to setup sqlalchemy in virtual environment. http://lucasmanual.com/mywiki/TurboGears#head-36fb4094da01b8c28e8bdca803c0f05774eb13b8 Installing SQLAlchemy in a virtualenv is the same as for any package on listed on PYPI: $ source myenv/bin/activate $ easy_install SQLAlchemy --~--~-~--~~~---~--~~ 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 in virtualenv Instructions
On Mon, Apr 14, 2008 at 11:30 AM, jason kirtland [EMAIL PROTECTED] wrote: Lukasz Szybalski wrote: Hello, Below you can find instructions on how to setup sqlalchemy in virtual environment. http://lucasmanual.com/mywiki/TurboGears#head-36fb4094da01b8c28e8bdca803c0f05774eb13b8 Installing SQLAlchemy in a virtualenv is the same as for any package on listed on PYPI: What does this line do? $ source myenv/bin/activate Which version of sqlalchemy does it install? current stable? trunk? or? $ easy_install SQLAlchemy Lucas --~--~-~--~~~---~--~~ 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 in virtualenv Instructions
Lukasz Szybalski wrote: On Mon, Apr 14, 2008 at 11:30 AM, jason kirtland [EMAIL PROTECTED] wrote: Lukasz Szybalski wrote: Hello, Below you can find instructions on how to setup sqlalchemy in virtual environment. http://lucasmanual.com/mywiki/TurboGears#head-36fb4094da01b8c28e8bdca803c0f05774eb13b8 Installing SQLAlchemy in a virtualenv is the same as for any package on listed on PYPI: What does this line do? $ source myenv/bin/activate http://pypi.python.org/pypi/virtualenv#activate-script Which version of sqlalchemy does it install? current stable? trunk? or? $ easy_install SQLAlchemy The latest on pypi. You can also do $ easy_install SQLAlchemy==dev # for svn trunk $ easy_install SQLAlchemy==0.4.5 # whatever version http://peak.telecommunity.com/DevCenter/EasyInstall --~--~-~--~~~---~--~~ 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 in virtualenv Instructions
Wow, you've been using virtualenv in the most difficult way possible bin/activate is a bash script that sets up you path and all other environment variables you need to use it. running souce bin/ activate (or . bin/activate) causes it to effect the current shell. Just type deactivate when you're ready to undo your venv. On Apr 14, 2008, at 12:38 PM, jason kirtland wrote: Lukasz Szybalski wrote: On Mon, Apr 14, 2008 at 11:30 AM, jason kirtland [EMAIL PROTECTED] wrote: Lukasz Szybalski wrote: Hello, Below you can find instructions on how to setup sqlalchemy in virtual environment. http://lucasmanual.com/mywiki/TurboGears#head-36fb4094da01b8c28e8bdca803c0f05774eb13b8 Installing SQLAlchemy in a virtualenv is the same as for any package on listed on PYPI: What does this line do? $ source myenv/bin/activate http://pypi.python.org/pypi/virtualenv#activate-script Which version of sqlalchemy does it install? current stable? trunk? or? $ easy_install SQLAlchemy The latest on pypi. You can also do $ easy_install SQLAlchemy==dev # for svn trunk $ easy_install SQLAlchemy==0.4.5 # whatever version http://peak.telecommunity.com/DevCenter/EasyInstall --~--~-~--~~~---~--~~ 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: Extension proposal
On Mon, 14 Apr 2008 11:49:40 +0100 Paul Johnston [EMAIL PROTECTED] wrote: There's an old version of my code here: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/ProcHash It's an nice function to have around: care to update the version on the wiki? ciao, lele. -- nickname: Lele Gaifax| Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas| comincerò ad aver paura di chi mi copia. [EMAIL PROTECTED] | -- Fortunato Depero, 1929. --~--~-~--~~~---~--~~ 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 in virtualenv Instructions
On Mon, Apr 14, 2008 at 11:38 AM, jason kirtland [EMAIL PROTECTED] wrote: Lukasz Szybalski wrote: On Mon, Apr 14, 2008 at 11:30 AM, jason kirtland [EMAIL PROTECTED] wrote: Lukasz Szybalski wrote: Hello, Below you can find instructions on how to setup sqlalchemy in virtual environment. http://lucasmanual.com/mywiki/TurboGears#head-36fb4094da01b8c28e8bdca803c0f05774eb13b8 Installing SQLAlchemy in a virtualenv is the same as for any package on listed on PYPI: What does this line do? $ source myenv/bin/activate http://pypi.python.org/pypi/virtualenv#activate-script Which version of sqlalchemy does it install? current stable? trunk? or? $ easy_install SQLAlchemy The latest on pypi. You can also do $ easy_install SQLAlchemy==dev # for svn trunk $ easy_install SQLAlchemy==0.4.5 # whatever version http://peak.telecommunity.com/DevCenter/EasyInstall Thanks guys, the active script was the last piece of the puzzle. Updated: http://lucasmanual.com/mywiki/TurboGears#head-36fb4094da01b8c28e8bdca803c0f05774eb13b8 Lucas --~--~-~--~~~---~--~~ 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 in virtualenv Instructions
You shouldn't be mucking about with the PYTHONPATH at all. before installing, activate the venv and ti will just do the right thing... On Apr 14, 2008, at 1:12 PM, Lukasz Szybalski wrote: On Mon, Apr 14, 2008 at 11:38 AM, jason kirtland [EMAIL PROTECTED] wrote: Lukasz Szybalski wrote: On Mon, Apr 14, 2008 at 11:30 AM, jason kirtland [EMAIL PROTECTED] wrote: Lukasz Szybalski wrote: Hello, Below you can find instructions on how to setup sqlalchemy in virtual environment. http://lucasmanual.com/mywiki/TurboGears#head-36fb4094da01b8c28e8bdca803c0f05774eb13b8 Installing SQLAlchemy in a virtualenv is the same as for any package on listed on PYPI: What does this line do? $ source myenv/bin/activate http://pypi.python.org/pypi/virtualenv#activate-script Which version of sqlalchemy does it install? current stable? trunk? or? $ easy_install SQLAlchemy The latest on pypi. You can also do $ easy_install SQLAlchemy==dev # for svn trunk $ easy_install SQLAlchemy==0.4.5 # whatever version http://peak.telecommunity.com/DevCenter/EasyInstall Thanks guys, the active script was the last piece of the puzzle. Updated: http://lucasmanual.com/mywiki/TurboGears#head-36fb4094da01b8c28e8bdca803c0f05774eb13b8 Lucas --~--~-~--~~~---~--~~ 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] Can you specify Foreign Key Constraint names? (Oracle limit on identifier length causing problems)
It is possible specify the name of a Foreign Key Constraint generated by a foreign key column specification? Looking at the documentation, the name parameter seems to refer to an existing database FK constraint rather than specifying the name of the generated constraint. (My problem is that I am migrating from SQLite to Oracle and its 30 char limit of identifiers is causing problems with Foreign key constraint names). Thanks for any help, Tim --~--~-~--~~~---~--~~ 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] ConcurrentModificationError with transactional sessions
When I execute this piece of code using a transactional, autoflushing session against SQLite, I get a ConcurrentModificationError on the final select: -- from sqlalchemy import * from sqlalchemy.orm import * eng = create_engine('sqlite://') sm = sessionmaker(autoflush=True, transactional=True, bind=eng) session =scoped_session(sm)() metadata=MetaData() people_table = Table('people', metadata, Column('id', Integer, primary_key=True), Column('name', String(40), nullable=False)) class Person(object): pass mapper(Person, people_table) metadata.create_all(bind=eng) p = Person() p.name = Eric session.save(p) p = session.query(Person).filter_by(name=Eric).one() p.name = John session.rollback() p = session.query(Person).filter_by(name=Eric).all() -- Using a non-transactional session (where the rollback is a no-op), I have no problem. Turning on SQL echo, I do see something a little odd--the ORM seems to be holding on to the UPDATE after the rollback. Interspersing the Python code and the emitted SQL, I see: -- p = Person() p.name = Eric session.save(p) p = session.query(Person).filter_by(name=Eric).one() ...BEGIN ...INSERT INTO people (name) VALUES (?) ...['Eric'] ...SELECT people.id AS people_id, people.name AS people_name ...FROM people ...WHERE people.name = ? ORDER BY people.oid ... LIMIT 2 OFFSET 0 ...['Eric'] p.name = John session.rollback() ...ROLLBACK p = session.query(Person).filter_by(name=Eric).all() ...BEGIN ...UPDATE people SET name=? WHERE people.id = ? ...['John', 1] ...ROLLBACK Traceback (most recent call last): [...] sqlalchemy.exceptions.ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1 -- Is this a bug, or am I misusing the transactional session? Thanks! -- Tim Lesher [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 with transactional sessions
On Apr 14, 2008, at 2:50 PM, Tim Lesher wrote: Is this a bug, or am I misusing the transactional session? until SQLA 0.4.6 is released including a new option called autosync=True, which we may combine against the other keyword options to just create a single value to set along the lines of transaction_sync='full', the Session usually needs to be cleared out (or at least expire_all() called) after a rollback() occurs. --~--~-~--~~~---~--~~ 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 with transactional sessions
On Apr 14, 3:06 pm, Michael Bayer [EMAIL PROTECTED] wrote: until SQLA 0.4.6 is released including a new option called autosync=True, which we may combine against the other keyword options to just create a single value to set along the lines of transaction_sync='full', the Session usually needs to be cleared out (or at least expire_all() called) after a rollback() occurs. Thanks--explicitly clearing out the session after any rollback fixed the problem. -- Tim Lesher [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 questions
Hi everyone. My coworkers and I have been working on a homebrew ORM for a year or two now, and we're considering switching to a different one, to cut down on some of the maintenance, and concentrate on our business logic.. Unfortunately, we have a rather old schema that we're locked into, that causes some interesting issues.. I can't tell directly from the docs if we can do some of things that we would require, so I have a bunch of questions.. Keep in mind, we can not change the schema, or the database (Oracle).. We're also open to other ORM's other than SA that might fit better, if you know of any.. SQLObject and Storm are out, as I don't see where they support Oracle... So, onto what we need: 1. Be able to call custom functions when a field is updated, sometimes filling other fields in the table. -- I believe this can be done with properties in the model. So i don't think is much of an issue.. 2. Force a field to be lowered all the time. When we insert, update or select the field, it needs to be lowered by the DB. But- We can not lower the field on the left side of a WHERE clause (ie: we must have: WHERE field1=lower(?), can not have: WHERE lower(field1) = lower(?) (that would kill our database performance...) 3. Handle multiple databases in the model.. We keep our user account data separate from our business data, but we still need to be able to access both from a single object. So we'll need to be able to do something like user.checkPassword() then user.getUserData(), where they each access different databases. 4. In the object model, hook into the object create, load, write/ update, and delete.. We've implemented an ACL type access on our objects, and would need to verify these ACLs for each action that touches the DB/.. 5. We also have a circumstance where we have 2 objects in difference databases that represent the same thing, but have a slightly different schema (someone named one field differently), is it possible to have a single object or table class to represent both? --John --~--~-~--~~~---~--~~ 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: Extension proposal
On Mon, 2008-14-04 at 10:26 -0400, Michael Bayer wrote: On Apr 14, 2008, at 10:11 AM, Paul Johnston wrote: Hi, In my case, the data is coming from FormEncode. I guess it could come from JSON, but that would be JSON client to server, which is not the usual way round. JSON is just an object encoding, in my mind it has no implications regarding clients/servers. The proposal is for a standalone function, I'm thinking you'd do something like: from sqlalchemy.ext.proc_hash import proc_hash ... proc_hash(myobj, mydata) As this is just plumbing python data structures into database objects, I think it's fitting to the SA-core goals. the function so far seems pretty use-case specific. (only works in one direction, is hardcoded to the obj.mapper convention, sort of looks like JSON but isn't, etc.) Even if it were JSON I dont think thats an SA core feature. But would still be useful to a lot of folks like me. Would it possibly be worth having extension-extensions? Like recommended extras or something that aren't in the SA core? I totally respect keeping the core lean and maintainable, but maybe a cookbooky section of the site with extras or something? just a thought! Iain --~--~-~--~~~---~--~~ 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: Mapper Issue Upgrading to 0.4.5
Wow that is fast! Thanks man ;-) On Apr 14, 5:51 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Apr 14, 2008, at 7:44 AM, Koen Bok wrote: Hey All, I was upgrading our app from 0.4.1 to 0.4.5 and this code broke: pg_user = Table('pg_user', metadata, Column('usesysid', Integer, primary_key=True), Column('usename', Unicode(), unique=True)) pg_group = Table('pg_group', metadata, Column('grosysid', Integer, primary_key=True), Column('groname', Unicode(), unique=True), Column('grolist', PGArray(unicode))) mapper(PGUser, pg_user, properties={ 'groups': relation(PGGroup, viewonly=True, primaryjoin=pg_user.c.usesysid==func.any(pg_group.c.grolist), foreign_keys=[pg_group.c.grolist])}) use the trunk and say: mapper(PGUser, pg_user, properties={ 'groups': relation(PGGroup, viewonly=True, primaryjoin=pg_user.c.usesysid==func.any(pg_group.c.grolist), foreign_keys=[pg_group.c.grolist], _local_remote_pairs=[pg_user.c.usesysid, pg_group.c.grolist] )}) this doesn't yet handle the full blown functions/casts in primaryjoin conditions ticket but its part of the way there. --~--~-~--~~~---~--~~ 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 questions
Hi, I think you'll do well to switch to an open library, I certainly found it worthwhile when I made a similar switch 18 months ago. And that's despite getting side-tracked making SA support MSSQL more completely :-) On you specific points: 1. Be able to call custom functions when a field is updated, sometimes 2. Force a field to be lowered all the time. When we insert, update or 3. Handle multiple databases in the model.. We keep our user account You won't have much trouble doing those. 4. In the object model, hook into the object create, load, write/ update, and delete.. We've implemented an ACL type access on our objects, and would need to verify these ACLs for each action that touches the DB/.. Not 100%, but I think you can do that with a MapperExtension. 5. We also have a circumstance where we have 2 objects in difference Hmmm, that's harder. You probably can create a proxy class that hides the distinction, but I've got a feeling you'll have some fun making this work in all the corner cases. Paul --~--~-~--~~~---~--~~ 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: Can you specify Foreign Key Constraint names? (Oracle limit on identifier length causing problems)
On Apr 14, 2008, at 1:54 PM, Dr.T wrote: It is possible specify the name of a Foreign Key Constraint generated by a foreign key column specification? Looking at the documentation, the name parameter seems to refer to an existing database FK constraint rather than specifying the name of the generated constraint. (My problem is that I am migrating from SQLite to Oracle and its 30 char limit of identifiers is causing problems with Foreign key constraint names). name on ForeignKeyConstraint is the name that would be placed within the CONSTRAINT name FOREIGN KEY clause of the generated DDL. --~--~-~--~~~---~--~~ 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 questions
On Apr 14, 2008, at 4:46 PM, John Sutherland wrote: 5. We also have a circumstance where we have 2 objects in difference databases that represent the same thing, but have a slightly different schema (someone named one field differently), is it possible to have a single object or table class to represent both? theres a lot of ways to do this kind of thing, the most simplistic is just to have two subclasses of a common class, and map each subclass distinctly - the actual column name can be normalized within the Table or mapper() construct across both classes. We have a feature called entity_name that also does this without the subclassing, but I'm trying to determine a use case for entity_name that isn't better accomplished by just using subclasses. --~--~-~--~~~---~--~~ 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: SQLError: (OperationalError) (2013, 'Lost connection to MySQL server during query')
Ross, Any luck with what you were trying... Having a similar problem but with MySQL 5.0.22 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---