[sqlalchemy] Re: Multiple encodings in my database

2008-06-27 Thread Hermann Himmelbauer
Am Freitag, 27. Juni 2008 01:20 schrieb Michael Bayer: first of all, the stack trace suggests you have not set the encoding parameter on create_engine() as it's still using UTF-8. If you mean that a single database column may have different encodings in different rows, you want to do your

[sqlalchemy] Re: Divide columns with possible zeroDivisionError

2008-06-27 Thread Dominique
I just want to add some significant fact: it really seems that the ordering is not correct only because the result of the columns division is (or at least should ) a float between 0 and 1. If I put figures that give a result to 1, it seems worling fine (ie 10 / 2 -- 5, 12 / 2 -- 6 will be

[sqlalchemy] Pickling/unpickling mapped class

2008-06-27 Thread Nabla
Hi, I'm new in SQLAlchemy (and also in Python in fact), can anyone help me with this (maybe silly) problem, please (it's just experiments, so please don't say - use framework XY instead your solution): Situation: - I have SimpleXMLRPCServer up and running (based on xmlrpclib) - working ok. - I

[sqlalchemy] Re: sharding id_chooser query_chooser

2008-06-27 Thread King Simon-NFHD78
Lilo wrote: My understanding of this query_chooser is that it's used when you want to execute orm's sql rather than raw sql. I don't quite understand what is visit_binary function do from attribute_shard.py example. What does it mean binary.operator, binary.left, binary.right.clause and

[sqlalchemy] How to totally close down db connection?

2008-06-27 Thread Werner F. Bruhin
Within my application (FB SQL) I use kinterbasdb.services to do backup and restore operations. No problem with the backup, but the restore is not working as SA seems to hang on to a connection. I do basically this to connect: self.engine = db.sa.create_engine(dburl, encoding='utf8',

[sqlalchemy] Operations on instance identity criterion with Many-to-Many self-relational table

2008-06-27 Thread MuTPu4
Hello! I have table wordforms and WordformMapping associated with it. Bi- directional self-relation is expressed by using association table with attributes named infinitives and forms. I am using Elixir for mapping definition so I cannot access association table with it's columns explicitly. I am

[sqlalchemy] Searching in all fields

2008-06-27 Thread [EMAIL PROTECTED]
Hi. I want to do robust algorithm for searching in tables...the simplest example is with table with no relations: stmt = u'SELECT * FROM ' stmt += str(b.clients.name) stmt += ' WHERE ' for c in b.Client.c: stmt += str(c)+' like \'%value%\' or ' clients =

[sqlalchemy] Re: Searching in all fields

2008-06-27 Thread Bobby Impollonia
If you do them as double percent signs ( '%%') then the python string formatting will replace them with single percent signs. On Fri, Jun 27, 2008 at 9:12 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi. I want to do robust algorithm for searching in tables...the simplest example is with

[sqlalchemy] Re: Multiple encodings in my database

2008-06-27 Thread Bobby Impollonia
If I am using the mysql-specific Column constructs with the charset option, will things be automatically encoded/ decoded by SA using that charset? Or is the charset option only used for Create Table? On Thu, Jun 26, 2008 at 7:20 PM, Michael Bayer [EMAIL PROTECTED] wrote: first of all, the

[sqlalchemy] Re: How to totally close down db connection?

2008-06-27 Thread Werner F. Bruhin
Werner F. Bruhin wrote: Within my application (FB SQL) I use kinterbasdb.services to do backup and restore operations. No problem with the backup, but the restore is not working as SA seems to hang on to a connection. I do basically this to connect: self.engine =

[sqlalchemy] Re: Searching in all fields

2008-06-27 Thread az
what is multisearch? sort of patternmatching? http://www.sqlalchemy.org/docs/05/ormtutorial.html#datamapping_querying_common query(A).filter( or_( A.c1.startswith(), A.c2.endswith(), A.c3.like('%alabal%'), ... )) u can generate the arguments of or_(...) On Friday 27 June

[sqlalchemy] Re: Searching in all fields

2008-06-27 Thread [EMAIL PROTECTED]
1) multisearch... I meant, that i want to create piece of code, that will automaticly search in all columns of a table So if I can use this function (or whatever it will be) for different tables with no change.. for example: I have a client(table) with address(related table one-to-one) and

[sqlalchemy] Re: Pickling/unpickling mapped class

2008-06-27 Thread Michael Bayer
On Jun 27, 2008, at 3:25 AM, Nabla wrote: Is there some easy solution of this problem? yes, the receiving application needs to have the same mapper() setup as the sender. If you use the declarative extension to setup your classes, this task is made easier. And additional question -

[sqlalchemy] Hi all

2008-06-27 Thread reetesh nigam
I made a web page . when i want to delete ant case then it shows this error. class 'sqlalchemy.exceptions.InvalidRequestError': ('The transaction is inactive due to a rollback in a subtransaction and should be closed', bound method Admin.deletestudy of radspeed.controllers.Admin instance at

[sqlalchemy] Re: Operations on instance identity criterion with Many-to-Many self-relational table

2008-06-27 Thread Gaetan de Menten
On Fri, Jun 27, 2008 at 2:44 PM, MuTPu4 [EMAIL PROTECTED] wrote: I have table wordforms and WordformMapping associated with it. Bi- directional self-relation is expressed by using association table with attributes named infinitives and forms. I am using Elixir for mapping definition so I

[sqlalchemy] Mapping not classes but just their keys

2008-06-27 Thread Paul-Michael Agapow
I've got a scenario here that seems as if it would be simple to solve, but it baffling me so far. Pointers in the right direction would be appreciated. I have a table of Foo objects, and FooCollection objects. In a classic many-to-many, a collection may contain a number of Foos, and any

[sqlalchemy] Re: Mapping not classes but just their keys

2008-06-27 Thread az
sorry to ride your thread but just to add related question: how can a reference be seen as its key/id and never the referred instance? turn off some postprocessing in properties/instrumentedAttr, or not map it at all? On Friday 27 June 2008 17:12:21 Paul-Michael Agapow wrote: I've got a

[sqlalchemy] Re: Searching in all fields

2008-06-27 Thread az
On Friday 27 June 2008 16:55:22 [EMAIL PROTECTED] wrote: 1) multisearch... I meant, that i want to create piece of code, that will automaticly search in all columns of a table So if I can use this function (or whatever it will be) for different tables with no change.. for example: I

[sqlalchemy] Re: Mapping not classes but just their keys

2008-06-27 Thread Michael Bayer
On Jun 27, 2008, at 10:12 AM, Paul-Michael Agapow wrote: But, I have a situation where I don't want FooCollection to actually contain the actual Foos, just a list of their keys. That is, Foos and FooCollections have to be handled separately. Obviously it will involve more paperwork, but

[sqlalchemy] Re: How to totally close down db connection?

2008-06-27 Thread Michael Bayer
On Jun 27, 2008, at 9:42 AM, Werner F. Bruhin wrote: After searching through the doc and doing some googling and trial and error I added an engine.dispose() to the closing routine and that seems to do the trick. Is this the correct approach? New version of closing db:

[sqlalchemy] Re: Mapping not classes but just their keys

2008-06-27 Thread Paul-Michael Agapow
My, that's fast turnaround :^) Thanks Michael. If I understand associationproxy right, it requires changes to be made to the class, which is a nuisance since one of SA's great strengths is that you don't have alter mapped classes. My classes are being used in non-DB applications, so I'd

[sqlalchemy] Re: Pickling/unpickling mapped class

2008-06-27 Thread Barry Hart
I use Gnosis Utils for a similar purpose. The API is similar to pickle, but if you need to control the details of the serialization (which fields get serialized and how), then that is quite different. Gnosis has a concept called mutators for this. Barry - Original Message From:

[sqlalchemy] Re: Mapping not classes but just their keys

2008-06-27 Thread Michael Bayer
On Jun 27, 2008, at 11:55 AM, Paul-Michael Agapow wrote: My, that's fast turnaround :^) Thanks Michael. If I understand associationproxy right, it requires changes to be made to the class, which is a nuisance since one of SA's great strengths is that you don't have alter mapped classes.

[sqlalchemy] Re: Multiple encodings in my database

2008-06-27 Thread jason kirtland
my understanding is that mysql works a little differently here. the column-level character sets are storage encodings only. all data to and from the database is encoded in the database connection's configured encoding. that can either be left as-is or converted to Unicode for you. Bobby

[sqlalchemy] Re: Pickling/unpickling mapped class

2008-06-27 Thread Petr Dlabal
I don't understand how can remote client application have the same mapper setup in situation where there is no direct connection to database to reflect the tables and map to the classes. In addition at the server side the classes are declared only like class XYZ(object):pass and the internal

[sqlalchemy] Re: Pickling/unpickling mapped class

2008-06-27 Thread Petr Dlabal
Thank you for the tip, I'll try Peter On Fri, Jun 27, 2008 at 6:09 PM, Barry Hart [EMAIL PROTECTED] wrote: I use Gnosis Utils for a similar purpose. The API is similar to pickle, but if you need to control the details of the serialization (which fields get serialized and how), then that is

[sqlalchemy] Re: Pickling/unpickling mapped class

2008-06-27 Thread az
u need to recreate the same graph of objects on the client side without the db underneath? just serialize all the objects u have then and send them over. what is to be serialized - maybe something like dict( (p.key, getattr(obj,key) ) for p in object_mapper(obj).iter_properties ) for

[sqlalchemy] Re: Divide columns with possible zeroDivisionError

2008-06-27 Thread Dominique
For those who may get stuck on this kind of things in the future: This works fine: session.execute(SELECT * ,(CASE WHEN Mytable.ColC = :i THEN :i WHEN Mytable.ColC :i THEN CAST(Mytable.ColB AS FLOAT) / Mytable.ColC END) AS Calcul FROM Mytable ORDER BY Calcul, {'i':0}) Thanks Dominique

[sqlalchemy] Re: Beginner: printing out queries

2008-06-27 Thread bukzor
Why is this so hard?? In SQLObject, this problem consists entirely of: print queryobj Bye all, --Buck On Jun 25, 11:23 am, Michael Bayer [EMAIL PROTECTED] wrote: On Jun 25, 2008, at 2:14 PM, bukzor wrote: Thanks. Trying to do this in 0.5, it seems someone deleted the Query.compile()

[sqlalchemy] Re: Pickling/unpickling mapped class

2008-06-27 Thread Michael Bayer
On Jun 27, 2008, at 12:23 PM, Petr Dlabal wrote: I don't understand how can remote client application have the same mapper setup in situation where there is no direct connection to database to reflect the tables and map to the classes. In addition at the server side the classes are

[sqlalchemy] Re: Beginner: printing out queries

2008-06-27 Thread Michael Bayer
On Jun 27, 2008, at 1:49 PM, bukzor wrote: Why is this so hard?? In SQLObject, this problem consists entirely of: print queryobj in SQLAlchemy it is also: print queryobj how is that harder ? --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] whats wrong with this query?

2008-06-27 Thread az
some aliasing is missing or what? see attached file (sa 0.4) print session.query( PVOwnership).join( 'param_value').all() ... sqlalchemy.exceptions.OperationalError: (OperationalError) no such column: ParamValue.db_id u'SELECT PVOwnership.param_value_id AS PVOwnership_param_value_id,

[sqlalchemy] Re: whats wrong with this query?

2008-06-27 Thread Michael Bayer
0.4 has trouble joining *to* a joined-table mapper, as below you can see its failing to convert model join paramvalue into a subquery. what's 0.5 say ? On Jun 27, 2008, at 2:45 PM, [EMAIL PROTECTED] wrote: some aliasing is missing or what? see attached file (sa 0.4) print

[sqlalchemy] Re: whats wrong with this query?

2008-06-27 Thread az
On Friday 27 June 2008 21:58:22 Michael Bayer wrote: 0.4 has trouble joining *to* a joined-table mapper, as below you can see its failing to convert model join paramvalue into a subquery. what's 0.5 say ? seems to work, on the simplified case at least. On Jun 27, 2008, at 2:45 PM, [EMAIL

[sqlalchemy] Re: whats wrong with this query?

2008-06-27 Thread Michael Bayer
On Jun 27, 2008, at 3:11 PM, [EMAIL PROTECTED] wrote: On Friday 27 June 2008 21:58:22 Michael Bayer wrote: 0.4 has trouble joining *to* a joined-table mapper, as below you can see its failing to convert model join paramvalue into a subquery. what's 0.5 say ? seems to work, on the

[sqlalchemy] Re: whats wrong with this query?

2008-06-27 Thread az
On Friday 27 June 2008 22:09:39 Michael Bayer wrote: On Jun 27, 2008, at 3:11 PM, [EMAIL PROTECTED] wrote: On Friday 27 June 2008 21:58:22 Michael Bayer wrote: 0.4 has trouble joining *to* a joined-table mapper, as below you can see its failing to convert model join paramvalue into a

[sqlalchemy] ProgrammingError: (ProgrammingError) current transaction is aborted, commands ignored until end of transaction block

2008-06-27 Thread Matt Haggard
I'm getting a ProgrammingError (I've pasted the last part of the traceback at the bottom of the page). The error comes from my first heavy-AJAX page in Pylons (postgres backend). If I cause too many AJAX requests at a time, or even after doing 3 non-overlapping AJAX requests, I get the error.

[sqlalchemy] Re: whats wrong with this query?

2008-06-27 Thread az
On Friday 27 June 2008 22:09:39 Michael Bayer wrote: On Jun 27, 2008, at 3:11 PM, [EMAIL PROTECTED] wrote: On Friday 27 June 2008 21:58:22 Michael Bayer wrote: 0.4 has trouble joining *to* a joined-table mapper, as below you can see its failing to convert model join paramvalue into a

[sqlalchemy] Re: ProgrammingError: (ProgrammingError) current transaction is aborted, commands ignored until end of transaction block

2008-06-27 Thread Michael Bayer
On Jun 27, 2008, at 4:03 PM, Matt Haggard wrote: I'm getting a ProgrammingError (I've pasted the last part of the traceback at the bottom of the page). The error comes from my first heavy-AJAX page in Pylons (postgres backend). If I cause too many AJAX requests at a time, or even after

[sqlalchemy] Re: ProgrammingError: (ProgrammingError) current transaction is aborted, commands ignored until end of transaction block

2008-06-27 Thread Matt Haggard
INSERT or UPDATE? I don't do any inserts with this code... only changing what's already there. Is an integrity constraint a PG thing, or SQLAlchemy model thing? And can I do Session.rollback() ? Thanks! On Jun 27, 2:19 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jun 27, 2008, at 4:03 PM,

[sqlalchemy] relation with same class/table on both sides

2008-06-27 Thread Tom Hogarty
Hello, I have the following scenario where I want the same class/table on both sides of a relation. person table - id - name manager table - person_id - manager_id I define both tables and a Person class, then create a relation in the person mapper like: 'manager' : relation(Person,

[sqlalchemy] Re: ProgrammingError: (ProgrammingError) current transaction is aborted, commands ignored until end of transaction block

2008-06-27 Thread Matt Haggard
I've fixed it by calling Session.clear() at the end of every controller action (it's in __after__()). I'm gonna go read about what that does -- right now it's just magic as far as I can tell :) Thanks again for the help, Michael On Jun 27, 3:30 pm, Michael Bayer [EMAIL PROTECTED] wrote: On

[sqlalchemy] Re: relation with same class/table on both sides

2008-06-27 Thread Michael Bayer
this relation will require you to configure primaryjoin and secondaryjoin (it should be raising an error without them). an example is attached. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group.

[sqlalchemy] time to remove create_session?

2008-06-27 Thread Jonathan Ellis
I replaced create_session in sqlsoup with scoped_session, which appears to have been the only reference to it. -Jonathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send

[sqlalchemy] Re: time to remove create_session?

2008-06-27 Thread Michael Bayer
two things are needed: 1. the official way to create a Session when all you want is a Session, with no custom builder class or anything like that. It should not be grossly inconsistent with the default arguments of the current sessionmaker() call. 2. all the myriad create_session() calls

[sqlalchemy] Re: time to remove create_session?

2008-06-27 Thread Martijn Faassen
Michael Bayer wrote: two things are needed: 1. the official way to create a Session when all you want is a Session, with no custom builder class or anything like that. It should not be grossly inconsistent with the default arguments of the current sessionmaker() call. 2. all the

[sqlalchemy] Re: relation with same class/table on both sides

2008-06-27 Thread Tom Hogarty
Wow, thank you very much for the detailed example. It looks like just what I need. I look forward to trying it out very soon. -Tom On Jun 27, 6:12 pm, Michael Bayer [EMAIL PROTECTED] wrote: this relation will require you to configure primaryjoin and   secondaryjoin (it should be raising an

[sqlalchemy] Re: time to remove create_session?

2008-06-27 Thread Michael Bayer
On Jun 27, 9:10 pm, Martijn Faassen [EMAIL PROTECTED] wrote: So creating the Session class directly is the right way to go? I switched from using that to create_session when I found out about the existence of this function, but I can switch back. well I think when you're calling