[sqlalchemy] Re: in_() function help
On 12/11/06, Jose Soares [EMAIL PROTECTED] wrote: Hi all, I need some help with in_ function (Pdb) print codice ['', '62714', '62601', '62602', '62612', '62614', '62603', '62610'] (Pdb) print type(codice) type 'list' (Pdb) print select([Attivita.c.cod_specie], Attivita.c.codice.in_(tuple(codice))) SELECT attivita.cod_specie FROM attivita WHERE attivita.codice = %(attivita_codice)s The in_() function expects to receive the list of values as multiple parameters. If it receives only one parameter, it assumes that that one parameter is a single value for the IN operation -- that is, you said something like Attivita.c.codice.in_('62601'). So change that in_() call to Attivita.c.codice.in_(*tuple(codice)) (or even just Attivita.c.codice.in_(*codice) for simplicity's sake) and you should get the expected results. -- Robin Munn [EMAIL PROTECTED] GPG key 0x4543D577 --~--~-~--~~~---~--~~ 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: in_() function help
Date: Mon, 11 Dec 2006 13:28:25 From: Jose Soares [EMAIL PROTECTED] To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] in_() function help Date: Mon, 11 Dec 2006 13:27:58 From: Robin Munn [EMAIL PROTECTED] To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] in_() function help Who needs the keys to the time machine next? I'm done using it now. :-) -- Robin Munn [EMAIL PROTECTED] GPG key 0x4543D577 --~--~-~--~~~---~--~~ 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: python ORM
hibernate didn't magically appear, it was refined with input from users over many years. if you want to help make sqlalchemy better for yours and other usage. its much better to give concrete examples, that can be used to improve it, then making grandiose negative statements. the idea behind sa's orm is indeed to obviate the need for most common application sql, if it fails for some reason on a given example, it would be helpful to actually here what the usage scenario/example is, perhaps you can post a comparison of a simple model between hibernate and sa. for example.. usage complaints as relates to session, are typically things that can be handled by app server, via app agnostic appserver integration. sa exposes various session/txn layers for application flexibility and for easier integration into frameworks or different programming styles, in much the same way that hibernate does, and arguably sa is more flexible here for different usage modes (although hibernate's scaling/deployment options, ie. caches are much nicer). cheers, kapil On Dec 9, 11:35 am, flyingfrog [EMAIL PROTECTED] wrote: Ok, this is my first approach with python + ORM, and i must say i can't do what i want with it... Before that i used java Hibernate, think you should know about. I've tried both SQLObject and SQLAlchemy but both have been a delusion :(, i'd like to share with you my considerations, hoping in some suggestions! SQLObject forces you to embed database code into your model classes, and i don't really want that. And it's really buggy! Too much for production usage. SQLAlchemy lets you define separately DB code and python classes, but then you hve a real duplication. And to use database functionalities you always need to access session objects or connections, making sql-like queries. And i don't want that. Thy're both good projects but none of them has catched the real objective: no more sql within the application logic. Hibernate does it, take a look! Anyway, maybe i didn't look so much into python world and there could be other tools, or other ways of using these tools for doing what i want to, please let me know if you know of any!! Bye --~--~-~--~~~---~--~~ 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: python ORM
On 12/9/06, flyingfrog [EMAIL PROTECTED] wrote: SQLAlchemy lets you define separately DB code and python classes, but then you hve a real duplication. And to use database functionalities you always need to access session objects or connections, making sql-like queries. And i don't want that. Unless Hibernate has changed almost entirely in the past two years (when I was last using it), you used session objects to control which of your objects were currently being managed by the ORM and you used OQL to query the database. I'd certainly be interested to see some examples of how it works now to see how it has changed... --~--~-~--~~~---~--~~ 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.3.2 released
yeah, still waiting for someone to show me some easy non-commercial library that can create a decent PDF out of either markdown, or HTML, or whatever... --~--~-~--~~~---~--~~ 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.3.2 released
We use (or rather, are going to use) reportlab for that - of course, that's commercial. But, we did get a lot of mileage out of the programmatic open-source kit before that. There was an RML-like thing floating around not too long ago called tinyreport or openreport or something like thatnever looked at it in-depth as we needed things like PageCatcher, and I haven't seen anything in Python that could do something like that, although I think there are some Java tools that might. FWIW, the Reportlab guys have been great to work with. Rick On 12/11/06, Michael Bayer [EMAIL PROTECTED] wrote: yeah, still waiting for someone to show me some easy non-commercial library that can create a decent PDF out of either markdown, or HTML, or whatever... --~--~-~--~~~---~--~~ 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: python ORM
On 12/11/06, Michael Bayer [EMAIL PROTECTED] wrote: Hibernate is pretty SQL oriented as well, and as I use it every day for my job I can say it has little to nothing over SA...harder to configure, more complex and less consistent behavior with regards to relationships, poorer database support (like forget about quoting and stuff), its create schema support sucks, no reflection, only one eager loading relation at a time, no union-based polymorphic loading, self-referential relationships are barely supported, and of course its very hard to integrate plain SQL/result set logic with it since its only an ORM. the only compelling features it has over SA are extra lazy loading and a second-level cache, which while ive used neither, could be implemented for SA someday. Sounds like you should port SA to Java so you can use it in your day job :) Kevin --~--~-~--~~~---~--~~ 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: python ORM
Or get a day job at a company that uses nothing but sqlalchemy, like mine :). Python coder resumes always accepted, especially from Mike. -shoe On 12/11/06, Kevin Dangoor [EMAIL PROTECTED] wrote: On 12/11/06, Michael Bayer [EMAIL PROTECTED] wrote: Hibernate is pretty SQL oriented as well, and as I use it every day for my job I can say it has little to nothing over SA...harder to configure, more complex and less consistent behavior with regards to relationships, poorer database support (like forget about quoting and stuff), its create schema support sucks, no reflection, only one eager loading relation at a time, no union-based polymorphic loading, self-referential relationships are barely supported, and of course its very hard to integrate plain SQL/result set logic with it since its only an ORM. the only compelling features it has over SA are extra lazy loading and a second-level cache, which while ive used neither, could be implemented for SA someday. Sounds like you should port SA to Java so you can use it in your day job :) Kevin -- --- I'd give my right arm to be ambidextrous. --- --~--~-~--~~~---~--~~ 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.3.2 released
Mike yeah, still waiting for someone to show me some easy Mike non-commercial library that can create a decent PDF out of either Mike markdown, or HTML, or whatever... Why not load the HTML into a web browser, print it, but select Save as PDF instead of completing the print? Are there distribution restrictions on such output? Skip --~--~-~--~~~---~--~~ 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.3.2 released
On 12/11/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Mike yeah, still waiting for someone to show me some easy Mike non-commercial library that can create a decent PDF out of either Mike markdown, or HTML, or whatever... Why not load the HTML into a web browser, print it, but select Save as PDF instead of completing the print? Are there distribution restrictions on such output? Do you know a way to do that programmatically? Otherwise it would add quite a bit of work to the usual docs release process, which Michael has automated pretty successfully so far. And even if there was a way to do that programmatically, it still wouldn't look as good as the PDF output of a script specifically designed to format Markdown (or HTML or whatever) into PDF. -- Robin Munn [EMAIL PROTECTED] GPG key 0x4543D577 --~--~-~--~~~---~--~~ 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.3.2 released
On 12/11/06, Robin Munn [EMAIL PROTECTED] wrote: On 12/11/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Mike yeah, still waiting for someone to show me some easy Mike non-commercial library that can create a decent PDF out of either Mike markdown, or HTML, or whatever... I was looking for something similar a while ago and found Pandoc[1]. I've not actually used it though as the client decided not to use Markdown syntax. It has a command line script called markdown2pdf which might help. [1]: http://sophos.berkeley.edu/macfarlane/pandoc/README.html -- Lee McFadden blog: http://www.splee.co.uk work: http://fireflisystems.com skype: fireflisystems --~--~-~--~~~---~--~~ 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.3.2 released
well id want the paging to line up correctly, get the TOC in there, stuff like that. otherwise theres not much advantage to PDF. --~--~-~--~~~---~--~~ 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: SA ORM delete efficiency
ml wrote: 1) Why does the SA the second SELECT for addresses to obtain primary keys? Why there is not a direct DELETE FROM addresses WHERE user_id=?? because SA's mapper is only a simple entity mapper. the way an instance gets deleted is by it being marked as deleted, and then the instance gets passed to its mapper in a list of items to be deleted. the origin of that delete marking, in this case due to a cascade, is not known at that point - only that the object was marked for deletion. the cascade rules are not linked into the query generation like that, and you could just as well marked all your child objects deleted individually without using any cascade at all. alternatively, if you didnt have the delete cascade, when deleting the parent item it would update all the child objects with a parent id of NULL, using a similar mechanism (i.e. updating individual objects, not an across-the-board update). to have the cascade rule wire itself into a delete from table where parent_id=x type of query is harder than you might think. the main thing that can go wrong is that the child items themselves might have dependencies. If I delete an object X, which has a child of Y, but then Y also has a child of Z, I have to somehow know to update/delete the Z instance before deleting all of X's children, which necessitates that SA knows explicitly that Y is attached to X, which necessitates a select. (and also would necessitate individual queries issued for each child of X). SA's current entity-based approach, which by default requires that it knows every instance individually (yes there is a way to do what you want, just read on), has no problem with this kind of scenario. another thing that can go wrong, is that X's child items might be hanging around in the session, but the session doesnt know that those child items are attached to X since they were loaded through some other means. when the mass delete (or update) of X's children occur, now theres a bunch of invalid objects hanging around in the session. *unless*, once again, we did a SELECT to explicitly figure out all the objects that are attached to X. so the entity approach is advantageous in that it does not screw up in the generic case, and a core philosophy of SA is to go for total correctness first, optimized cases second. 2) If it is neccessary to do this SELECT, why is the SA selecting all columns? E.g. I will have 1 user with 10 addresses - an idea of selecting all 10 addresses to get their id's is spooky :-) so now for how to do what you want. it does the select by default because it needs to know about all the child items individually when the parent is being deleted, else it wouldnt be able to delete or update them and there would be a constraint violation. but you can disable this by using passive_deletes=True flag on the relationship so that SA does not load in all the objects upon a delete operation, and you combine it with ON DELETE (CASCADE/SET NULL) directives on your table so that your database handles the en-masse delete for you (this is another core SA philosophy, dont do what the database can already do). passive_deletes is a fairly new setting and someone on IRC was complaining that it wasnt completely working (but then he couldnt show me a test case), so if you see your ORM loading a bunch of objects just to delete them with that flag on, send a test case to the list so I can improve upon its functioning. as far as working the mass-delete into SA's ORM directly, it might make a nice feature add, but because it would be very hard to make it automatic and smart enough to detect conditions where it *cant* be used, as well as the surprise side effects it has, would almost be better as just an explcit user-defined setting cascade_deletes...which is essentially the same as the ON DELETE rule you put on your table (and therefore is largely a reinvention of the wheel, unless youre stuck with MySQL ISAM tables). --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---