[sqlalchemy] Re: share objects with threads and scoped_session

2009-08-06 Thread Ants Aasma
On Aug 5, 10:59 pm, drakkan drakkan1...@gmail.com wrote: Seems that once I defined a scoped session as: Session = scoped_session(sessionmaker()) I can switch to a non scoped session simply calling: sess=Session() ... is this the intended behaviuor? Yes that is intended behavior. But if

[sqlalchemy] Re: Relation w/ declarative

2009-08-06 Thread Wichert Akkerman
On 8/6/09 09:30 , werner wrote: IIRC correctly the __init__ section is only needed if you want to do: add = Address('an email address') I never do this, i.e. I assign like this add = Address() add.email_address = 'an email address' You can also do this with the default declarative base

[sqlalchemy] Re: GIS support for SQLAlchemy

2009-08-06 Thread Ants Aasma
I don't have a lot of experience with geodatabases so I can't evaluate this from a practical perspective, but I do have a couple of thoughts about the general design. I'm not too keen on having the geometry functions as methods on the comparator. Having them there creates a namespace collision

[sqlalchemy] Re: MySQL DDL broken with autoincrement-column in multipart-key using InnoDB

2009-08-06 Thread Christian Schwanke
Hi Michael, the problem does not occur, when the autoincrement is set to True, so your fix works correctly. The problem of the generated id not being set only turned up again, when I was experimenting with autoincrement=False (to fix the dialect problem at table creation time) in conjunction

[sqlalchemy] Bug with ORM session???

2009-08-06 Thread sagblmi
Hi, I can't figure how that occurs but I'm facing to a stange ?bug?. (I try to write a testcase but without success) After a call to session.query(MClass).get(id), the returned object has all these attributes marked as unloaded If I do a session.refresh(myObject), attributes are correctly

[sqlalchemy] Re: Bug with ORM session???

2009-08-06 Thread sagblmi
I don't know if it's relevant with my prob but my application ends with the following errors Exception exceptions.AttributeError: 'NoneType' object has no attribute 'from_attribute' in bound method MutableAttrInstanceState._cleanup of sqlalchemy.orm.state.MutableAttrInstanceState object at

[sqlalchemy] Re: GIS support for SQLAlchemy

2009-08-06 Thread Sanjiv Singh
Hi Ants, Thanks for the valuable feedback. On Thu, Aug 6, 2009 at 2:30 PM, Ants Aasmaants.aa...@gmail.com wrote: I don't have a lot of experience with geodatabases so I can't evaluate this from a practical perspective, but I do have a couple of thoughts about the general design. I'm not

[sqlalchemy] How to avoid SQLAlchemy generating transactions for read-only queries

2009-08-06 Thread phrrn...@googlemail.com
We are rolling out some SQLAlchemy infrastructure at work and came across an interesting issue. We are using the mssql dialect on top of pyodbc to talk to both SQL Server and Sybase dataservers. We use bound metadata and scoped session_maker with autocommit=True. First off, the problem we

[sqlalchemy] Re: GIS support for SQLAlchemy

2009-08-06 Thread Ants Aasma
On Aug 6, 4:09 pm, Sanjiv Singh singhsanj...@gmail.com wrote: Also the GeometryDDL and Geometry classes could use some refactoring to support extensibility of adding new dialects. Probably via a registry that maps dialects to their geometry implementations. Also, the GeometryDDL doesn't

[sqlalchemy] Re: GIS support for SQLAlchemy

2009-08-06 Thread Sanjiv Singh
Awesome. Thanks for elaborating. Sanjiv On Thu, Aug 6, 2009 at 7:38 PM, Ants Aasmaants.aa...@gmail.com wrote: On Aug 6, 4:09 pm, Sanjiv Singh singhsanj...@gmail.com wrote: Also the GeometryDDL and Geometry classes could use some refactoring to support extensibility of adding new dialects.

[sqlalchemy] Re: Bug with ORM session???

2009-08-06 Thread Michael Bayer
sagblmi wrote: I don't know if it's relevant with my prob but my application ends with the following errors Exception exceptions.AttributeError: 'NoneType' object has no attribute 'from_attribute' in bound method MutableAttrInstanceState._cleanup of

[sqlalchemy] Re: How to avoid SQLAlchemy generating transactions for read-only queries

2009-08-06 Thread Michael Bayer
phrrn...@googlemail.com wrote: We are rolling out some SQLAlchemy infrastructure at work and came across an interesting issue. We are using the mssql dialect on top of pyodbc to talk to both SQL Server and Sybase dataservers. We use bound metadata and scoped session_maker with

[sqlalchemy] Re: Relation w/ declarative

2009-08-06 Thread allen.fowler
On Aug 6, 3:30 am, werner wbru...@free.fr wrote: I never do this, i.e. I assign like this add = Address() add.email_address = 'an email address' In what way is the Address object expected to be instantiated such that it receives the correct user id? You just do this and SA will take

[sqlalchemy] Re: Relation w/ declarative

2009-08-06 Thread allen.fowler
On Aug 6, 4:59 am, Wichert Akkerman wich...@wiggy.net wrote: On 8/6/09 09:30 , werner wrote: IIRC correctly the __init__ section is only needed if you want to do: add = Address('an email address') I never do this, i.e. I assign like this add = Address() add.email_address = 'an

[sqlalchemy] Re: How to avoid SQLAlchemy generating transactions for read-only queries

2009-08-06 Thread Michael Bayer
Michael Bayer wrote: Some DBAPI's provide autocommit modes, but since these are not standardized or universally available, and because SQLA has its own autocommit that works very nicely and consistently, SQLA has no support for them. I dont know what Pyodbc provides. note however that

[sqlalchemy] Re: Suggestions for db connect string configuration?

2009-08-06 Thread allen.fowler
On Aug 5, 6:29 pm, AF allen.fow...@yahoo.com wrote: Hello, Where do you folks recommend storing the database connection string in my application.  Clearly not in the same file with my declaratively defined model objects. And more generally, how do you recommend laying out an SQLAlchemy

[sqlalchemy] Re: Advice on modeling a many-to-many relationship

2009-08-06 Thread Hollister
Still having a little trouble...here are the relevant mappings: orm.mapper(Keyphrase, keyphrase_table, properties = { 'message':orm.relation(Message, backref='keyphrase'), 'campaign':orm.relation(Campaign, backref='keyphrase'), 'actions':orm.relation(KeyphraseAction),

[sqlalchemy] Re: Advice on modeling a many-to-many relationship

2009-08-06 Thread Hollister
Also, the following does nothing at all (does not delete and throws no errors): for ka in kp.actions: del ka But this: del kp.actions Throws the same assertion error. On Aug 6, 11:01 am, Hollister a.hollister.willi...@gmail.com wrote: Still having a little trouble...here

[sqlalchemy] Re: Bug with ORM session???

2009-08-06 Thread sagblmi
When looking for the session status I've session.is_active == True When checking the log file I don't have 'commit ' between working and failing code. I don't know if it's normal but I've a strange behaviour with session.query().get() For the same Class and Id, If I call X times

[sqlalchemy] Re: Bug with ORM session???

2009-08-06 Thread Michael Bayer
sagblmi wrote: When looking for the session status I've session.is_active == True When checking the log file I don't have 'commit ' between working and failing code. I don't know if it's normal but I've a strange behaviour with session.query().get() For the same Class and Id, If I call X

[sqlalchemy] Re: Advice on modeling a many-to-many relationship

2009-08-06 Thread Michael Bayer
you're probably looking for delete-orphan cascade in this case, if objects have foreign keys on their primary key columns you'd like them to be deleted when deassociated with their parent object. Hollister wrote: Also, the following does nothing at all (does not delete and throws no errors):

[sqlalchemy] Declarative Base: remote_side single_parent

2009-08-06 Thread AF
Hello, What is the correct way to use remote_side single_parent relation parameters under Declarative Base? I'm trying to create an Adjacency List Relationship as suggested in the docs, but I am not sure how to do this with Declarative Base. I tried: children = relation(Node,

[sqlalchemy] Re: Relation w/ declarative

2009-08-06 Thread werner
Allen, allen.fowler wrote: ... What is that __repr__ function doing exactly? Looks interesting. It is really useful, and yes Michael comes up with beauties like this. Produces nice print output, i.e.: print 'after flush' print con print add Will give you: after flush

[sqlalchemy] ORM and SQL expression package in same web app with use of threadlocal

2009-08-06 Thread n00b
greetings, i've been using mysql, SA ORM (scoped_session) with cherrypy and all is fine. however, i'm also using some MySQLdb-based connections and getting pretty tired of the 'mysql gone away' issues and lame db.ping () workarounds. hence, i want to move everything to SA using the

[sqlalchemy] Re: Suggestions for db connect string configuration?

2009-08-06 Thread john smallberries
Woops I thought I was reading a pylons group when I replied to your message. Not much of that will make any sense in a pure sqlalchemy world. -- W On Aug 6, 7:56 am, allen.fowler allen.fow...@yahoo.com wrote: On Aug 5, 6:29 pm, AF allen.fow...@yahoo.com wrote: Hello, Where do you

[sqlalchemy] Re: Suggestions for db connect string configuration?

2009-08-06 Thread john smallberries
That's what .ini files are for (that thing you generated with make- config). Search for instructions regarding sqlalchemy.dburi in a .ini file if you want to have your connection magically setup for you and a single database is enough. For working with multiple databases, there's no universal

[sqlalchemy] ORM performance questions

2009-08-06 Thread Brian Granger
Hi, I am using sqlalchemy through its orm layer. The basic flow of my program is this: 1. Download about 18000 web pages and store the raw HTML in a table 2. Iterate through each web page and use pyparsing to parse it. I then insert the results of that parsing into about a dozen different

[sqlalchemy] interpret (string) NULLs as empty strings, not None

2009-08-06 Thread Catherine Devlin
When populating objects through the ORM, I'd like to interpret all NULL values fetched from VARCHAR2 / NVARCHAR2 columns in the database as empty strings ('') instead of `None`s. Is there any way to set that behavior globally? Failing that, how would you recommend doing it? (I'm using Oracle,

[sqlalchemy] Re: interpret (string) NULLs as empty strings, not None

2009-08-06 Thread Michael Bayer
Catherine Devlin wrote: When populating objects through the ORM, I'd like to interpret all NULL values fetched from VARCHAR2 / NVARCHAR2 columns in the database as empty strings ('') instead of `None`s. Is there any way to set that behavior globally? Failing that, how would you recommend

[sqlalchemy] Re: ORM performance questions

2009-08-06 Thread Michael Bayer
Brian Granger wrote: Hi, I am using sqlalchemy through its orm layer. The basic flow of my program is this: 1. Download about 18000 web pages and store the raw HTML in a table 2. Iterate through each web page and use pyparsing to parse it. I then insert the results of that parsing

[sqlalchemy] Re: Declarative Base: remote_side single_parent

2009-08-06 Thread Michael Bayer
allen.fowler wrote: I tried: children = relation(Node, backref=backref(parent, remote_side=nodes.id)) got it to work with: remote_side=[id] But: 1) Why is remote_side a list? in this case you could just say remote_side=id. its optionally a list if multiple columns occur on the

[sqlalchemy] Re: Declarative Base: remote_side single_parent

2009-08-06 Thread allen.fowler
On Aug 6, 4:05 pm, Michael Bayer mike...@zzzcomputing.com wrote: allen.fowler wrote: I tried: children = relation(Node, backref=backref(parent, remote_side=nodes.id)) got it to work with: remote_side=[id] But: 1) Why is remote_side a list? in this case you could just say

[sqlalchemy] Materialized Path for SQLAlchemy Declarative Base

2009-08-06 Thread AF
Hello all, Has anyone here used the sqlamp: Materialized Path for SQLAlchemy library? I am wondering: 1) Does it seem to work well? 2) Did you use it with Declarative Base, and if so, how did you configure it? Thank you, :) --~--~-~--~~~---~--~~ You received

[sqlalchemy] Re: How to avoid SQLAlchemy generating transactions for read-only queries

2009-08-06 Thread phrrn...@googlemail.com
Thanks for the information Mike. I do have a listener in place already but decided to poke in the configuration directly when creating the engine: 'connect_args' : {'autocommit' : True, } I found some very interesting results by experimenting with vanilla pyodbc and

[sqlalchemy] Re: How to avoid SQLAlchemy generating transactions for read-only queries

2009-08-06 Thread Michael Bayer
On Aug 6, 2009, at 8:39 PM, phrrn...@googlemail.com wrote: Thanks for the information Mike. I do have a listener in place already but decided to poke in the configuration directly when creating the engine: 'connect_args' : {'autocommit' : True, } I found some

[sqlalchemy] Re: How to avoid SQLAlchemy generating transactions for read-only queries

2009-08-06 Thread phrrn...@googlemail.com
They differ mainly on 'new' stuff (where new is anything 15 years old!) but for the kind of SELECT queries generated by SA we haven't seen any problems at all (yet!). We decided to go ahead and use the mssql dialect for read-only apps and postpone the remaining work on the Sybase dialect on top

[sqlalchemy] django like inspectdb

2009-08-06 Thread dusans
is there something similar to inspectdb in sqlalchemy where it returns orm classes for tables already in the db? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to