[sqlalchemy] Weird mapper() behaviour (bug?)

2009-03-02 Thread Karlo Lozovina
Hi guys! Here goes the code sample: from sqlalchemy import create_engine, MetaData from sqlalchemy import Table, Column, ForeignKey, Integer from sqlalchemy.orm import sessionmaker, mapper, relation metadata = MetaData() engine = create_engine('sqlite:///:memory:', echo=True) parent_table =

[sqlalchemy] Re: Weird mapper() behaviour (bug?)

2009-03-02 Thread Karlo Lozovina
On Mar 3, 1:03 am, Michael Bayer mike...@zzzcomputing.com wrote: its a bug, there's an isinstance(str) that should be   isinstance(basestring).  please file a trac ticket. Done, here it is: http://www.sqlalchemy.org/trac/ticket/1330 -- Karlo Lozovina

[sqlalchemy] Properly closing all database connections

2008-05-06 Thread Karlo Lozovina
I'm using SA with SQLite, and after executing session.close() and clear_mappers(), on Linux, lsof still says my SQLite file is open. Running engine.dispose() seems to finally close it, but I'm not sure if that's the proper way? Thanks, Karlo. --~--~-~--~~~---~--~~

[sqlalchemy] Re: Properly closing all database connections

2008-05-06 Thread Karlo Lozovina
On May 6, 10:53 pm, jason kirtland [EMAIL PROTECTED] wrote: That's correct.  The engine holds the connection pool and dispose() will close the connections it manages. Thanks... it's weird there's no mention of it in the docs. -- Karlo Lozovina - Mosor

[sqlalchemy] Duplication of rows in many-to-many relationship

2008-05-04 Thread Karlo Lozovina
Let's say I have two classes A and B, and I want instances of both classes, to have a list of each other, that is, many-to-many relationship. For a shorthand, a means instance of A, and b is an instance of B. For example: a.bs is a list, full of instances of class B. Similarly, b.as is a list,

[sqlalchemy] Re: Duplication of rows in many-to-many relationship

2008-05-04 Thread Karlo Lozovina
On May 4, 10:40 pm, Barry Hart [EMAIL PROTECTED] wrote: By chance, in your mappers, are you declaring two relationships instead of one relation with a backref? Yep, that was it, thanks! Should have read the docs more carefully ;). As a side note, once you straighten this out, you may want

[sqlalchemy] Linking column default values?

2007-11-21 Thread Karlo Lozovina
Hi guys, sorry for the vague subject, here is my problem. Let's say I have the following table: a = Table('aaa', meta, Column('id', Integer, primary_key=True), Column('id2', Integer)) class A(object): pass mapper(A, a) I want the default value of A.id2 to be that of a A.id. So, for

[sqlalchemy] SQLite and ON CONFLICT clause?

2007-03-19 Thread Karlo Lozovina
Hi all, browsing the SQLAlchemy docs I coudn't find any references to a particular SQLite feature, ON CONFLICT clause (http://www.sqlite.org/ lang_conflict.html), is there any support for this in SA? What I want to do is this, create my database as such: CREATE TABLE songs( id INTEGER

[sqlalchemy] SA support for SQLite ATTACH?

2007-03-09 Thread Karlo Lozovina
Greetings everyone, does SQLAlchemy somehow support SQLites' ATTACH DATABASE statement? I have a in-memory SQLite database that I want to dump to file, so I was thinking of using ATTACH to do it. Any other ideas welcome ;). Thanks in advance, Karlo.

[sqlalchemy] Re: SA support for SQLite ATTACH?

2007-03-09 Thread Karlo Lozovina
On Mar 9, 4:33 pm, Michael Bayer [EMAIL PROTECTED] wrote: attach database ...wow i never knew it had that ! if its a matter of issuing the string attach database, just use literal text() or engine.execute(). Me neither ;), until the other day I started looking for an efficient way to dump