[sqlalchemy] Replacing a Session Engine

2008-11-24 Thread Koen Bok
Hey I was wondering if it was possible to replace an engine in a session. It does not seem to work, but maybe I'm doing something really stupid. http://pastie.org/322501 Kindest regards, Koen Bok - madebysofa.com --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: Replacing a Session Engine

2008-11-24 Thread Koen Bok
as opposed to pending, so the example updates a row that isn't there. you need to build a copy constructor on Person and make a new, non-persistent Person object for your second engine.   the Session can't implicitly figure out what your intent is. Koen Bok wrote: Hey I was wondering

[sqlalchemy] Smart Caching Mapper Question

2008-05-28 Thread Koen Bok
Hey All, I have a conceptual question. You have two ways to get relations; lazy and nonlazy. Nonlazy works great for saving queries but can get pretty slow with complicated joins. So I was wondering if there was a third way; pre fetching all the data for relations and let the mapper get the

[sqlalchemy] Re: Smart Caching Mapper Question

2008-05-28 Thread Koen Bok
Yep, exactly that. It would speed up my (UI) app immensely. Any ideas how to approach something like that? On May 28, 5:07 pm, [EMAIL PROTECTED] wrote: some time ago i posted a list of my ideas along this..http://groups.google.com/group/sqlalchemy/browse_thread/thread/d88696... be ware:

[sqlalchemy] Re: problems with py2app

2008-04-26 Thread Koen Bok
Hey Iain, If you build apps with py2app it tries to figure out which modules to include automatically. If these modules are nested in some weird way it sometimes chokes. A solution is to import that module by hand in your main script (your-app-name.py) or telling py2app it needs to add the

[sqlalchemy] Re: Get Mapper for Table

2008-04-17 Thread Koen Bok
Got it, thanks! On Apr 16, 4:26 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Apr 16, 2008, at 10:13 AM, Koen Bok wrote: Hey all, Before 0.4.5 I used this code to get the mapped class for a table. It worked fine, but mapper_registry was made private in 0.4.5 and the private function

[sqlalchemy] Get Mapper for Table

2008-04-16 Thread Koen Bok
Hey all, Before 0.4.5 I used this code to get the mapped class for a table. It worked fine, but mapper_registry was made private in 0.4.5 and the private function does not behave the same way for some reason. But as this code is pretty nasty anyway I was wondering if there was a better way to do

[sqlalchemy] Re: Mapper Issue Upgrading to 0.4.5

2008-04-15 Thread Koen Bok
=[pg_group.c.grolist], _local_remote_pairs=[(pg_user.c.usesysid, pg_group.c.grolist)])}) On Apr 14, 11:26 pm, Koen Bok [EMAIL PROTECTED] wrote: 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

[sqlalchemy] Mapper Issue Upgrading to 0.4.5

2008-04-14 Thread Koen Bok
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,

[sqlalchemy] Re: Mapper Issue Upgrading to 0.4.5

2008-04-14 Thread Koen Bok
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

[sqlalchemy] Re: downtime

2008-03-24 Thread Koen Bok
Hey Mike, We (Sofa) just sponsored a year 512 hosting. Check the paypal. And keep up the good work! Koen Bok - madebysofa.com On Mar 24, 8:39 pm, Michael Bayer [EMAIL PROTECTED] wrote: another theory is that I had some vhost config that wasn't synced up   on both DNS servers that I use

[sqlalchemy] Re: foreign key support in SQLite

2008-01-28 Thread Koen Bok
be something to say for pythonizing triggers so they become database agnostic, but I am not even sure if that is possible given all the different triggers different databases can have. What do you mean by 'unstable internals' in SQLAlchemy? Kindest regards, Koen Bok On Jan 28, 12:03 pm, Manlio

[sqlalchemy] Polymorphic from multiple columns

2007-12-03 Thread Koen Bok
I'd like to make a polymorphic mapper based on two columns. Is that possible? See example code here: http://paste.pocoo.org/show/13799/ Thanks, Koen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group.

[sqlalchemy] Expire Objects from other Thread

2007-12-01 Thread Koen Bok
This is quite hackish, but just an experiment for me. We use listen/notify in our app. A seperate thread is listening for notifications from updated rows in the table. If one is received I'd like to expire an object in the Session cache so it gets refetched the next time it is accessed. I have

[sqlalchemy] Re: Expire Objects from other Thread

2007-12-01 Thread Koen Bok
it does as my tests pass fine. You just earned yourself another sushi meal ;-) Koen On Dec 1, 8:40 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Dec 1, 2007, at 9:33 AM, Koen Bok wrote: This is quite hackish, but just an experiment for me. We use listen/notify in our app. A seperate

[sqlalchemy] Polymorphic Mapper with Custom Column Type

2007-11-25 Thread Koen Bok
Hi, I am trying to store numeric values for an object inverted in the database. For that I created a custom TypeDecorator. It work's fine. But I only want to apply it to one inherited object type for that object. See example code at: http://paste.pocoo.org/show/12411/ Thanks, Koen

[sqlalchemy] Merge Questions

2007-11-20 Thread Koen Bok
I have some questions about pickling/merging objects. I have written example code to demonstrate: http://pastie.caboo.se/120146 Kindest regards, Koen Bok --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy

[sqlalchemy] Re: Merge Questions

2007-11-20 Thread Koen Bok
Aight, thanks for the explanation! Koen On Nov 20, 5:02 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Nov 20, 2007, at 6:19 AM, Koen Bok wrote: I have some questions about pickling/merging objects. I have written example code to demonstrate:http://pastie.caboo.se/120146 Kindest

[sqlalchemy] Re: SQLAlchemy 0.4.1 released

2007-11-18 Thread Koen Bok
Thanks Mike. Cool stuff! On Nov 19, 1:26 am, Michael Bayer [EMAIL PROTECTED] wrote: Hello alchemers - This is an awesome release. I'm excited about this one. With our new shiny clean 0.4 codebase, internals are starting to look a lot more intelligent, and new things are becoming

[sqlalchemy] Temporary Disable Session.mapper with Scoping

2007-11-15 Thread Koen Bok
Hi, I use scoped_session in our project for auto object saving which is great. But when I initialize a new database I need to flush some objects with another engine. I could not find a nice way to do that so I created a new session with it's own engine and merged the objects into that one and

[sqlalchemy] Re: Temporary Disable Session.mapper with Scoping

2007-11-15 Thread Koen Bok
Ok, I could do that. On Nov 15, 4:09 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Nov 15, 2007, at 9:06 AM, Koen Bok wrote: Hi, I use scoped_session in our project for auto object saving which is great. But when I initialize a new database I need to flush some objects with another

[sqlalchemy] Re: Object Init Bug?

2007-11-14 Thread Koen Bok
Yep. That was it. Stupid me... On Nov 13, 4:10 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Nov 13, 2007, at 8:25 AM, Koen Bok wrote: Hi, I have this strange bug or problem... I have a basic class like this mapped to a table with the same name. Metatype is a relation to the metatype

[sqlalchemy] Object Init Bug?

2007-11-13 Thread Koen Bok
Hi, I have this strange bug or problem... I have a basic class like this mapped to a table with the same name. Metatype is a relation to the metatype object. class MetaData(DBObject): def __init__(self, metatype, value, item): self.metatype = metatype

[sqlalchemy] Code Organisation

2007-11-07 Thread Koen Bok
Hi there, We have a pretty large project by now and we run into import loops. So I decided to restructure the code, and I hoped some people with more experience can comment on this. The basic problem is this: We have the database object code, mappers and tables neatly organized in one module

[sqlalchemy] Load Lazy Relation in Separate Thread

2007-09-13 Thread Koen Bok
Hi, I am doing some optimizations on our app, and one thing I was wondering is if I can have a lazy relation loading in a separate thread. The way I'd like to use it is like this. I have a list with products, and these products show a graph with stock levels. To draw this graph, the object

[sqlalchemy] Re: reviving migrate

2007-09-09 Thread Koen Bok
I have no info on this, but I have seen the current owner on this and the migrate group. It would be awesome if migrate would work again. Koen On Sep 9, 2:53 pm, Jan Dittberner [EMAIL PROTECTED] wrote: I read the discussion regarding the status of the migrate tool and would like to help with

[sqlalchemy] Re: Get Table/Column Sequence Names

2007-09-08 Thread Koen Bok
/catalog-pg-attrdef.htmlfor more info. Hopefully someone else who knows SQLAlchemy better will know whether it's possible to easily extract this info via metadata. Orest -Original Message- From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Koen Bok Sent

[sqlalchemy] max/coalesce bug in 0.4?

2007-09-06 Thread Koen Bok
Hi there, I am upgrading my app to 0.4 and while it's going pretty well, I encountered something strange. I have the following code: request_table = Table('request', metadata, Column('id', Integer, primary_key=True), ... Column('metanumberstate', Integer, nullable=False,

[sqlalchemy] Re: max/coalesce bug in 0.4?

2007-09-06 Thread Koen Bok
, Koen Bok wrote: Aight, that would be cool. So this still has to be implemented then, right? embedded select works eh ? try making your default that: default=select([func.max(metanumber.id)]) --~--~-~--~~~---~--~~ You received this message because you

[sqlalchemy] Connection Timeout

2007-09-05 Thread Koen Bok
My app saves bookmarks to different Postgres servers, and tries to connect at login. But if the server from the bookmark is not reachable or down, it only times out after like 2 minutes. So I could either check if the host is available before connecting (telnetlib connection to the Postgres port)

[sqlalchemy] Re: Generate new id

2007-08-19 Thread Koen Bok
Dear Gennady, I'm afraid flushing is your only option, as you need the next number from the database sequence. What I do is flushing some objects in their init methods already. Kindest regards, Koen Bok On Aug 19, 7:22 am, Gennady [EMAIL PROTECTED] wrote: Hello, I'm a new sqlalchemy user

[sqlalchemy] Serialize ClauseLists

2007-08-14 Thread Koen Bok
For our app we'd like the user to construct and save search queries that we execute on the database. My first thought was to construct something like: predicate = and_(or_(item.c.id5, item.c.id3), item.c.name.like('aap'))) And save this to a pickle column in the database. But it gives: raise

[sqlalchemy] Cumulative Select

2007-07-24 Thread Koen Bok
I need to do a cumulative select on postgres, and I got it to work with some extreme SQL query, but I was wondering if it could be done more easily without having to drop to SQL but with SQLAlchemy statements. Let's say I have a table with stock transactions like this: Transaction id

[sqlalchemy] Re: Cumulative Select

2007-07-24 Thread Koen Bok
going to deprecate scalar=True and instead have you sayselect(...).scalar() On Jul 24, 2007, at 9:38 AM, Koen Bok wrote: I need to do a cumulative select on postgres, and I got it to work with some extreme SQL query, but I was wondering if it could be done more easily without having

[sqlalchemy] Many to many to same table

2007-07-20 Thread Koen Bok
() session.save(Item('Koen Bok')) session.save(Item('Dirk Stoop')) session.flush() # And now we should be able to do something like this: items = session.query(Item).select() for item in items: for i in items: item.items.append(i) item.collections.append(i

[sqlalchemy] Re: Many to many to same table

2007-07-20 Thread Koen Bok
) assert dirk in koen.collections assert koen in dirk.items session.flush() session.clear() (koen, dirk) = session.query(Item).order_by(desc (item_table.c.name)).all() assert dirk in koen.collections assert koen in dirk.items On Jul 20, 2007, at 4:00 PM, Koen Bok wrote: from sqlalchemy

[sqlalchemy] No update in cascade

2007-07-06 Thread Koen Bok
I have a strange situation. If someone _really_ needs to know why I could explain. When an object gets deleted by SQLAlchemy, it's related objects are getting updated setting their foreign keys referring to the deleted items to NULL. But what if I don't want that to happen? Viewonly is not an

[sqlalchemy] Re: Get URL from engine

2007-04-29 Thread Koen Bok
That would be very nice. You have my vote. Koen On Apr 29, 5:13 am, Michael Bayer [EMAIL PROTECTED] wrote: On Apr 28, 2007, at 10:34 AM, Koen Bok wrote: Is there a nice way to get the URL from a given engine? not at the moment...the url goes into a create function and gets thrown

[sqlalchemy] GRANT weirdness.

2007-04-29 Thread Koen Bok
I want to grant permissions through sqlalchemy, but for some reason if I let an engine execute the sql it does not work: Code: from sqlalchemy import * engine = create_engine('postgres://localhost/Test') engine.echo = True engine.execute('CREATE USER testuser;') engine.execute('GRANT SELECT

[sqlalchemy] Re: GRANT weirdness.

2007-04-29 Thread Koen Bok
And ofcourse the first result should be this in the above mail: Test=# \z testtable Access privileges for database Test Schema | Name | Type | Access privileges +---+---+ public | testtable | table | {koen=arwdxt/koen} (1 row)

[sqlalchemy] Re: GRANT weirdness.

2007-04-29 Thread Koen Bok
Yep that's it. If anyone has the same just do this: engine.execute('BEGIN;GRANT SELECT ON TABLE checkout_info TO testuser;COMMIT;') Ciao Koen On Apr 29, 4:51 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Apr 29, 2007, at 9:28 AM, Koen Bok wrote: I want to grant permissions through

[sqlalchemy] Catching username password errors

2007-04-23 Thread Koen Bok
I am trying to catch username password errors to show in the interface. But somehow I cannot catch the exeption. I wrap everything in a try except, but the exeption is still throwed and my app stops functioning. What am I doing wrong? Koen loginInfo = (

[sqlalchemy] Postgres user management and SQLAlchemy

2007-04-16 Thread Koen Bok
I wondered if it was possible to manage users inside postgres with the help of SQLAlchemy. But I guess Postgres users are special objects and not just rows in a table. I tried to do this, but it did not work. from sqlalchemy import * metadata = BoundMetaData('postgres://127.0.0.1/template1')

[sqlalchemy] Re: Find out which objects were deleted

2007-04-15 Thread Koen Bok
Yep, and I want to know them after the flush :-) On Apr 15, 7:11 pm, Michael Bayer [EMAIL PROTECTED] wrote: session has a deleted accessor with all items marked as deleted. (its cleared out on flush()). On Apr 15, 2007, at 11:20 AM, Koen Bok wrote: Is there a nice way to find out

[sqlalchemy] Re: Column to default to itself

2007-04-13 Thread Koen Bok
Ok, I'd rather handle it on the database level. Is that just a matter of creating a function and calling it on insert? Koen On Apr 13, 4:47 am, Ants Aasma [EMAIL PROTECTED] wrote: On Apr 13, 2:47 am, Jorge Godoy [EMAIL PROTECTED] wrote: IF you insist on doing that at your code, make the

[sqlalchemy] Re: Column to default to itself

2007-04-13 Thread Koen Bok
this or can it cause complications? On Apr 13, 11:23 am, Koen Bok [EMAIL PROTECTED] wrote: Ok, I'd rather handle it on the database level. Is that just a matter of creating a function and calling it on insert? Koen On Apr 13, 4:47 am, Ants Aasma [EMAIL PROTECTED] wrote: On Apr 13, 2:47 am

[sqlalchemy] Re: Putting Session.flush in a seperate thread

2007-04-10 Thread Koen Bok
the elegant way would be to not worry about the thread scope of a connection and just use connection pooling normally. pull out a connection when needed, close it when complete (which is really just a return to the connection pool). keep the scope of those two operations local to

[sqlalchemy] Putting Session.flush in a seperate thread

2007-04-09 Thread Koen Bok
We are building a GUI app, and we were thinking about wrapping session.flush() in a thread with a timer that detects a timeout. That way we would have better performace and we can generate warnings if the connection goes down. Do you guys think this is smart, or are there complications? I tried

[sqlalchemy] Re: Changing lazy property for primary mapper on the fly

2007-03-26 Thread Koen Bok
Ok, thanks! On Mar 26, 4:26 am, Michael Bayer [EMAIL PROTECTED] wrote: no. do a clear_mappers() and build your mappers again if you need to change the base configuration. On Mar 25, 2007, at 3:35 PM, Koen Bok wrote: I get this, but that's only on a particular query object. That makes

[sqlalchemy] Unwanted Cascaded Deletes

2007-03-25 Thread Koen Bok
I have a mapper like this: mapper(Request, request_table, properties={ [SOME MORE STUFF] 'stock': relation(Stock, lazy=True, uselist=False, primaryjoin=and_( request_table.c.id_item==stock_request.c.id_product,

[sqlalchemy] Changing lazy property for primary mapper on the fly

2007-03-25 Thread Koen Bok
Is it possible to change the lazy property of a primary mapper of an object's relation on the fly so from then on it wil change the eager loading of that relation. I want to use this for a small debug window in my app where I can change these on the fly to test which settings are optimal for the

[sqlalchemy] Re: Changing lazy property for primary mapper on the fly

2007-03-25 Thread Koen Bok
25, 2007, at 6:50 AM, Koen Bok wrote: Is it possible to change the lazy property of a primary mapper of an object's relation on the fly so from then on it wil change the eager loading of that relation. I want to use this for a small debug window in my app where I can change

[sqlalchemy] Mapper with custom outerjoin and sum functions

2007-03-25 Thread Koen Bok
Hello again! I need a mapper that does an outer join on another table. stock_request_join = sql.outerjoin(request_table, stock_table, and_( request_table.c.id_item==stock_table.c.id_product, request_table.c.id_location==stock_table.c.id_location,

[sqlalchemy] Eager loading self referential mapper

2007-03-23 Thread Koen Bok
Could anyone please explain me a little why self referantial mappers cannot be eager-loading. Is this not yet integrated in SQLAlchemy or theoratically impossible or impractical? Ciao Koen --~--~-~--~~~---~--~~ You received this message because you are

[sqlalchemy] Re: Eager loading self referential mapper

2007-03-23 Thread Koen Bok
Yeah, I am sure the tree will never be deeper than 3 or 4 levels. Koen On Mar 23, 5:24 pm, Andreas Jung [EMAIL PROTECTED] wrote: --On 23. März 2007 16:14:26 + Koen Bok [EMAIL PROTECTED] wrote: Could anyone please explain me a little why self referantial mappers cannot be eager

[sqlalchemy] Re: Using mapper with custom select creates unneeded subquery

2007-03-22 Thread Koen Bok
- From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Koen Bok Sent: 22 March 2007 10:47 To: sqlalchemy Subject: [sqlalchemy] Re: Using mapper with custom select creates unneeded subquery Let me post some sample code with that: mapper(Request, request_table

[sqlalchemy] Complicated Mapper with Count Function

2007-02-25 Thread Koen Bok
Dear all. I have to make a complicated mapper, and I need a little help. We have a list of products. These products have stock, each individual stock item has an entry in the stockproduct table. So to get the total stock we need to count the items in the stock database. We can filter them by a