[sqlalchemy] Problems with typeadapter on HSTORE
I’ve been looking to make a simple typeadapter based on the HSTORE data type in postgres to do some value coercion and I have been having some problems. I want to coerce the individual values inside my dictionary before they are put into the postgres HSTORE column and when I select keys, I want to coerce them back. What methods do I need to subclass to intercept subkey/indexing operations as well as full assignment operations? Normally for a simpler datatype I’d just implement process_bind_param, process_result_value but that hasn't been working the way I expect it to with HSTORE. If it makes the problem simpler I don’t need the MutableExtension to work so I only need to coerce data on the first assignment to the column. I'll primarily be selecting data like Query(MyObjectClass.MyHSTOREType['somekey']) but occasionally, I may be doing Query(MyObjectClass.MyHSTOREType) and would like my postgres-python coercion to work in both scenarios. Thanks in advance -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] Unique Many-to-Many
Yeah I confirmed set collections don't actually fix it, I guess setting a rollback point is required. Is there any chance this is a difference between the way mysql does table locking and postgres? The collections in question have lazy=dynamic set so I'm wondering if previously it wasn't a problem because the DB was locking the whole table? On Monday, March 17, 2014 8:49:57 PM UTC-7, Michael Bayer wrote: On Mar 17, 2014, at 10:38 PM, Morgan McClure mcclure...@gmail.comjavascript: wrote: I'm trying to make a many-to-many relationship using sqlalchemy 0.9 and postgres If I put a unique constraint on the join table, and I add a duplicate, I get an integrity error. If I change the collection class to set, it won't double commit, however a set prevents me from using things like order_by. In my scenario, I'm massively multi-threaded and so the check-before commit methodology won't work (proven it breaks with 24 processes). Is it possible to get a nice elegant solution to this without defining a custom collection_class? I believe this is a regression (enhancement?) from version 0.8, but on 0.8 I was using mysql and now I'm using postgres. im not seeing how this is any kind of change from version 8 to 9, or even from version 7, 6, or 5; a list will certainly allow duplicates that will give you integrity errors, and a set certainly won’t. using many processes of course you can’t coordinate those in memory with a set, only the database knows the right answer. the approach here unfortunately is to use traditional means of adding new rows while checking for an existing one. which means either emitting a SELECT first and ensuring adequate coordination between these 24 processes using transaction isolation or locks, or using a simple optimistic approach where you start a savepoint (begin_nested()), attempt the operation, catch IntegrityError and then continue with the row now known to be already present. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
[sqlalchemy] Unique Many-to-Many
I'm trying to make a many-to-many relationship using sqlalchemy 0.9 and postgres If I put a unique constraint on the join table, and I add a duplicate, I get an integrity error. If I change the collection class to set, it won't double commit, however a set prevents me from using things like order_by. In my scenario, I'm massively multi-threaded and so the check-before commit methodology won't work (proven it breaks with 24 processes). Is it possible to get a nice elegant solution to this without defining a custom collection_class? I believe this is a regression (enhancement?) from version 0.8, but on 0.8 I was using mysql and now I'm using postgres. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] WITH (nolock) on all queries
We have to use the 'WITH (nolock)' because of legacy requirements; however, we will look into the isolation level comment and see what our DBAs say. Oh, and thanks for the help Mike, we'll test that patch and see if it works and report back (along with anything we get on the isolation level). Thanks, Doug On Tue, Jun 28, 2011 at 12:39 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Jun 28, 2011, at 2:55 PM, Alexandre Conrad wrote: I must have it wrong, I admit I don't quite understand the arguments of .with_hint() session.query(User).with_hint(User, 'WITH (nolock)').get(1) if that makes any sense (I wonder why I'd need to pass the User object again). additional info, per this SO answer: http://stackoverflow.com/questions/210171/effect-of-nolock-hint-in-select-statements/210443#210443 NOLOCK is functionally equivalent to an isolation level of READ UNCOMMITTED. The main difference is that you can use NOLOCK on some tables but not others, if you choose. If you plan to use NOLOCK on all tables in a complex query, then using SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED is easier, because you don't have to apply the hint to every table. why not set transaction isolation level on the connection ? this is a lot easier. A connection event can set that up on all connections. 2011/6/28 Michael Bayer mike...@zzzcomputing.com: On Jun 28, 2011, at 12:55 PM, Alexandre Conrad wrote: Hi list, So I am working on a project with SQLAlchemy using MSSQL as a back-end DB and I need to add a WITH (nolock) statement to all my queries implicitly. Even for the .get(pk_id) method. Mike actually pointed me to the .with_hint() method on the Query object but I couldn't get it to work. PS: I also noticed that there was a .with_lockmode() and I was wondering if that could help as this can be passed at the Session level, which implies that it will affect all queries (whatever this does). well with_hint() should add it but if you really want to be heavyhanded you can override the compilation of sqlalchemy.expression.sql.Select to do it, using the form described at: http://www.sqlalchemy.org/docs/core/compiler.html#changing-the-default-compilation-of-existing-constructs Thanks, -- Alex | twitter.com/alexconrad -- 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. -- 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. -- Alex | twitter.com/alexconrad -- 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. -- Doug Morgan http://about.me/doug.morgan -- 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] Unique ID's
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 number. What do you guys suggest for this, is there a particular method which works well for some of you? Thanks in advance Morgan --~--~-~--~~~---~--~~ 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: Schema display
Hi Guys, Maybe I'm missing something. I tried to import boundMetadata and this has become MetaData, and I'm getting an import error ImportError: No module named sqlalchemy_schemadisplay So I was wondering if this has moved out of MetaData or been renamed. Morgan Michael Bayer wrote: where its always been... http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SchemaDisplay On Jan 5, 2008, at 7:58 PM, [EMAIL PROTECTED] wrote: Hi Guys, I was wondering where the function create_schema_graph has gone, or what it has changed to. Any assistance would be appreciated. Let me know, Morgan --~--~-~--~~~---~--~~ 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: Conventions for creating SQL alchemy apps
Thanks for that, make sense to me. svilen wrote: some may-be-stupid answers: - see the number of lines per file - split it into app-field-related parts, not SA-arhitectural parts - hell, do as it is easier - start as one file, once u hit some limit of your nerve(r)s, split.. but do keep one single file as main entrance point On Thursday 20 December 2007 09:37:26 Morgan wrote: Hi Guys, This may be a stupid question so flame away I don't care, but I have been wondering. Is there a better way to layout your SQL alchemy files that my random method? Does anyone have a convention that works well for them. I'm only asking this because I cannot decide how I want to lay out the SQLAlchemy component of my application. I'm thinking of putting it all in files like engines.py, mapping.py, metadata.py etc or should I just shove this all in one file. Let me know if I have had too much coffee or not. Morgan --~--~-~--~~~---~--~~ 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] Conventions for creating SQL alchemy apps
Hi Guys, This may be a stupid question so flame away I don't care, but I have been wondering. Is there a better way to layout your SQL alchemy files that my random method? Does anyone have a convention that works well for them. I'm only asking this because I cannot decide how I want to lay out the SQLAlchemy component of my application. I'm thinking of putting it all in files like engines.py, mapping.py, metadata.py etc or should I just shove this all in one file. Let me know if I have had too much coffee or not. Morgan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---