[sqlalchemy] sqlalchemy.exc.InvalidRequestError: Mapper properties (i.e. deferred,column_property(), relationship(), etc.) must be declared as @declared_attr callables on declarative mixin classes.

2016-01-15 Thread Andreas Jung
Hi, I currently have the following mix-in class construction (based on the documentation http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/mixins.html ) Base = declarative_base() class BaseCountry(object): """ Managed through Kotti """ @declared_attr def __tablename

[sqlalchemy] Re: SA 0.8.0 UnicodeDecodeError with Postgres 9.1.9

2013-04-18 Thread Andreas Jung
Problem seems to be related how I moved the database (pg_dump + pg_restore). After moving the database files directory I can no longer reproduce this error. -aj On Friday, April 19, 2013 8:36:58 AM UTC+2, Andreas Jung wrote: > > Hi there, > > I receive the following weird Unicod

[sqlalchemy] SA 0.8.0 UnicodeDecodeError with Postgres 9.1.9

2013-04-18 Thread Andreas Jung
Hi there, I receive the following weird UnicodeDecodeError after copying our production database into a testing environment. On the production server everything is working fine, on the testing server I get this error. Both installation including OS are basically identically (except SA 0.8.0b2 v

[sqlalchemy] Storing a two dimensional list structure with different item types in Postgres 9.1

2012-12-20 Thread Andreas Jung
Using Postgres 9.1, SqlAlchemy 0.8. I need to store information like [ [10, 'liters', 'tea'], [20, 'milliliters', 'salt'], ] as one column into Postgres. What is the best way to do this? Of course I use a second table with a 1:N relationship I am thinking about using the Postgres Array typ

[sqlalchemy] XX and YY are both of the same direction error

2009-04-02 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I am getting the following error after upgrading from post-0.5.2 version (SVN) to 0.5.3: == ERROR: testToolLookupVisitedBy (tool.tests.test_tool_lookup.TestToolLookup) - -

[sqlalchemy] Re: Mapping an existing database

2009-03-29 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 29.03.2009 2:44 Uhr, j...@robinlea.com wrote: > Hi, > > I'm new to SQLAlchemy. I am trying to use Pylons to expose an existing > database in a browser. All the introductory material assumes I am > going to create the database from python object def

[sqlalchemy] Re: sqlalchemy and json

2009-03-25 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 25.03.2009 7:17 Uhr, alex wrote: > sorry, but I need numeric of dicts {1:{"id":"1","name":"Alex"},2: > {"id":"2","name":"Nick"}} to use this in ajax-call JSON does not know about date-ish types. You have to convert such fields explicitly e.g. to a

[sqlalchemy] Re: session of an object

2009-03-24 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 24.03.2009 23:01 Uhr, Alessandro Dentella wrote: > Hi, > > is there a way to get the session an object belongs to? > I have been looking around and cannot find any function/way for that... > object_session(obj) - -aj -BEGIN PGP SIGNATURE

[sqlalchemy] Re: sqlalchemy and json

2009-03-24 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 24.03.2009 13:45 Uhr, alex wrote: > Hello. > > I need to get query from sqlalchemy in json format. > > query like > query_name = session.query(model.Users); > > How to format like > {{"id":"1","name":"Alex"},{"id":"2","name":"Nick"}.} Th

[sqlalchemy] Re: Application performance

2009-03-19 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 19.03.2009 11:14 Uhr, Alex K wrote: > Well, it does not affect the performance and I still get: The Python profiler will tell you exactly about bottlenecks. So go and profile your code. - -aj -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (Da

[sqlalchemy] Re: Any one tried to use SqlAlchemy with XML RPC?

2009-03-19 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 19.03.2009 8:32 Uhr, Arthur Pemberton wrote: > 2009/3/19 Andreas Jung : >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> On 19.03.2009 6:49 Uhr, Arthur Pemberton wrote: >> >>> SQLAlchemy needs a c

[sqlalchemy] Re: Any one tried to use SqlAlchemy with XML RPC?

2009-03-18 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 19.03.2009 6:49 Uhr, Arthur Pemberton wrote: > > SQLAlchemy needs a concept of Data Transfer Objects so that it can be > easily transmitted and reconstituted as necessary and everyone doesn't > have to reimplemented the idea themselves. There are

[sqlalchemy] Re: Any one tried to use SqlAlchemy with XML RPC?

2009-03-18 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 19.03.2009 5:24 Uhr, 一首诗 wrote: > This is my ORM class definition: > > #= > class User(Base): > __tablename__ = 'b_taa_user' > > user_id = Column(Integer, primary_key=True, autoincrement=True, > nullable=False) # 用户

[sqlalchemy] Re: newbie problem

2009-02-18 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 18.02.2009 15:26 Uhr, Marcin Krol wrote: > > This is pretty obvious, 'id' integer column has not been filled. But I > have no idea how to remedy this, since this seems to be dependent on > smth in the guts of sqlalchemy. Help! > Column('id',In

[sqlalchemy] Re: How to write a self 2 self relationship?

2009-02-16 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 This is covered by the decl. layer documentation (including examples): - either use strings for the parameter or - you write outside the class scope User.sons = relation() - -aj On 16.02.2009 9:57 Uhr, 一首诗 wrote: > I tried to write : > > #

[sqlalchemy] [SA0.5.2/PG] KeyError: pg_expression_2

2009-02-01 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi there, using SA 0.5.2/Postgres 7.4.22. Reflecting an existing database gives me this: (Pdb) c /local/HRS2/Devel/junga/tb-dev/eggs/SQLAlchemy-0.5.2-py2.4.egg/sqlalchemy/engine/base.py:1265: SAWarning: Skipped unsupported reflection of expression-b

[sqlalchemy] Re: parent/child relationship: what am I doing wrong?

2009-02-01 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 The syntax is basically same. Look at the standard documentation and examples for relation() and apply it to the decl layer. - -aj On 01.02.2009 16:17 Uhr, Eric Ongerth wrote: > Kevin, the default behavior is for relations to be represented by > list

[sqlalchemy] Re: INTERVAL 1 DAY in ORM

2009-01-25 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 26.01.2009 6:23 Uhr, Jan Koprowski wrote: > Hi ! > > I get some query: > > DELETE FROM passwordrequest WHERE requested_at <= (NOW() - INTERVAL 1 > DAY) > > which delete all requests older then one day. How can I get this > effect in SQLAlchemy

[sqlalchemy] Re: How to improve performance of sqlalchemy based application?

2009-01-18 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 18.01.2009 16:32 Uhr, Victor Lin wrote: > Hi, > So I think that would be better to buffer data and flush them. This is easily spoken the implementation pattern of SA: unit-of-work. You might check the documentation. - -aj -BEGIN PGP SIGNATURE-

[sqlalchemy] Re: [Decl. Layer] Multiple mappers for one table?

2009-01-13 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 13.01.2009 15:52 Uhr, Michael Bayer wrote: > > On Jan 13, 2009, at 8:19 AM, Andreas Jung wrote: > >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> Is it possible to define multiple mappers for one tab

[sqlalchemy] [Decl. Layer] Multiple mappers for one table?

2009-01-13 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Is it possible to define multiple mappers for one table? Usecase: I have one big table (60 cols) and one big mapper class. For some reporting I don't need only a small number of cols. For performance reasons I would like to load the related rows using

[sqlalchemy] Re: Suggestions for abbreviations

2009-01-11 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11.01.2009 12:13 Uhr, Cito wrote: > I wonder why declarative_base() doesn't simply set __tablename__ to > the name of the class by default (maybe translating camelcase to > lowercase with underscores). Please no implicit magic under the hood. You

[sqlalchemy] Re: [SA0.5/Postgres 7.4] SAVEPOINT sent although not supported through Postgres 7.4

2009-01-02 Thread Andreas Jung
On 02.01.2009 18:11 Uhr, Michael Bayer wrote: > > On Jan 2, 2009, at 4:24 AM, Andreas Jung wrote: > >> Hi there, >> >> running SA 0.5rc4, psycopg2 together with Postgres 7.4.22. >> >> I am currently migrating a Zope application from SA 0.3 to SA 0.5. >

[sqlalchemy] [SA0.5/Postgres 7.4] SAVEPOINT sent although not supported through Postgres 7.4

2009-01-02 Thread Andreas Jung
Hi there, running SA 0.5rc4, psycopg2 together with Postgres 7.4.22. I am currently migrating a Zope application from SA 0.3 to SA 0.5. While the migration worked for a bigger application I have an issue with a smaller application. SA issues a "SAVEPOINT XXX" command although Postgres 7.4 obviou

[sqlalchemy] Re: Sanity checks

2009-01-01 Thread Andreas Jung
On 01.01.2009 13:40 Uhr, vctr...@gmail.com wrote: > Is there a way to do some sanity check through thr SQLAlchemy. > Check like - SQL Service is running, DB exists etc. huh? You can perform some stupid queries against the related database or table and catch error using Python's exception handling.

[sqlalchemy] Re: Callback on save when value of field has changed?

2008-12-27 Thread Andreas Jung
On 27.12.2008 11:06 Uhr, Jim Jones wrote: > Hi List, > > I have this simple model (in declarative style): > > class Item( Base ): > __tablename__ = 'items' > desc = Column( 'desc', UnicodeText(), nullable=False ) > email = Column( 'email', UnicodeText(), nullable=False ) > > How can

[sqlalchemy] Re: Updating existing objects

2008-12-26 Thread Andreas Jung
On 27.12.2008 3:06 Uhr, Eric Abrahamsen wrote: > Sorry for the very beginner question, but I haven't been able to find > a good discussion of this issue online (possibly because it's too > basic). > > I'm using sqlalchemy as part of a basic web-based CRUD-style CMS. I've > got the Create, Read and

[sqlalchemy] Re: Efficient dictificationof result sets

2008-12-18 Thread Andreas Jung
On 19.12.2008 2:57 Uhr, Michael Bayer wrote: > > On Dec 18, 2008, at 3:04 PM, Andreas Jung wrote: > >> On 10.12.2008 20:36 Uhr, Michael Bayer wrote: >>> On Dec 10, 2008, at 2:27 PM, Andreas Jung wrote: >>> >>>> Hi there, >>>> >>>&

[sqlalchemy] Re: Efficient dictificationof result sets

2008-12-18 Thread Andreas Jung
On 10.12.2008 20:36 Uhr, Michael Bayer wrote: > > On Dec 10, 2008, at 2:27 PM, Andreas Jung wrote: > >> Hi there, >> >> is there some more efficient way for dictifying a resultset other than >> >> lst = list() >> for row in session.query(...).all(): &g

[sqlalchemy] Re: [SA0.5b4/Postgres 7.4] ValueError: 'need more than 0 values to unpack'

2008-12-17 Thread Andreas Jung
On 16.12.2008 17:09 Uhr, Michael Bayer wrote: > I see that. There is definitely other model code not seen here being > compiled. Since I see you're in a unit test, perhaps a previous test has > not been cleaned up completely ? You can see within the trace that its a > PropertyLoader being initiali

[sqlalchemy] Re: [SA0.5b4/Postgres 7.4] ValueError: 'need more than 0 values to unpack'

2008-12-16 Thread Andreas Jung
trace is specific to a > relation(), which you haven't illustrated in your setup. > > > On Dec 16, 2008, at 7:31 AM, Andreas Jung wrote: > > > Hi, > > > > I have a fairly complex model using the declarative layer. > > For a

[sqlalchemy] [SA0.5b4/Postgres 7.4] ValueError: 'need more than 0 values to unpack'

2008-12-16 Thread Andreas Jung
Hi, I have a fairly complex model using the declarative layer. For a simple table 'fassung' Toolbox2=# \d fassung Table "public.fassung" Column| Type | Modifiers -+---+---

[sqlalchemy] Re: Setting up a self-referential mapper using the declarative layer

2008-12-11 Thread Andreas Jung
On 11.12.2008 11:10 Uhr, [EMAIL PROTECTED] wrote: > afaik, u can supply strings instead of real things everywhere in those > arguments.. they are eval()ed against some context at later time. > This works to some degree: class Hierarchies(Base): __tablename__ = 'hierarchies' __table_args

[sqlalchemy] Setting up a self-referential mapper using the declarative layer

2008-12-11 Thread Andreas Jung
Can the decl. layer be used to setup a self-referential mapper like class Foo(Base): __tablename__ = 'foo' __table_args__ = {'autoload' : True} children = relation(Foo, primaryjoin=Foo.parent_id==Foo.id) parent = relation(Foo, primary_join=Foo.parent_id=Foo.id,

[sqlalchemy] Efficient dictificationof result sets

2008-12-10 Thread Andreas Jung
Hi there, is there some more efficient way for dictifying a resultset other than lst = list() for row in session.query(...).all(): d = self.__dict__.copy() for k in d.keys(): if k.startswith('_sa'): del d[k] lst.append(d) Especially the loop of the keys tak

[sqlalchemy] Re: any easy way to make a just-out-of-db object readonly?

2008-12-05 Thread Andreas Jung
On 05.12.2008 17:10 Uhr, [EMAIL PROTECTED] wrote: > i'm asking about SA-related stuff, i know how to handle the python > side. how to "lock" relations, collections etc - how to make an > instance readonly? > > and eventualy if it is poosible after that to unlock that instance at > some point - so l

[sqlalchemy] Re: ProgrammingError: (ProgrammingError) Fehler »syntax error« bei »SAVEPOINT«

2008-11-23 Thread Andreas Jung
Oopps...I was using the wrong database...someone switched the port numbers :-> Andreas On 23.11.2008 15:17 Uhr, Andreas Jung wrote: > I am getting the following error with SA 0.5.0rc4 and Postgres 8.1 > while trying some integration work with SQLAlchemy and Plone (on top of > Zop

[sqlalchemy] ProgrammingError: (ProgrammingError) Feh ler »syntax error« bei »SAVEPOINT«

2008-11-23 Thread Andreas Jung
I am getting the following error with SA 0.5.0rc4 and Postgres 8.1 while trying some integration work with SQLAlchemy and Plone (on top of Zope). Any idea? Andreas get(): ab23df631c18ea2c9ae7be8321f647dd 2008-11-23 15:13:39 ERROR root Exception while rendering an error message Traceback (most

[sqlalchemy] Re: Load capabilities with default pool_size and max_overflow

2008-07-15 Thread Andreas Jung
--On 15. Juli 2008 22:32:35 -0700 Fotinakis <[EMAIL PROTECTED]> wrote: Hello SQLAlchemists, What is (or what do you think is) the load that SQLAlchemy can handle with the default engine options of pool_size=5 and max_overflow=10? The application I'm working on has the potential for bursts of

[sqlalchemy] Re: Implementation patterns for initializing the model and obtaining the mappers

2008-06-29 Thread Andreas Jung
--On 29. Juni 2008 16:57:16 -0400 Michael Bayer <[EMAIL PROTECTED]> wrote: On Jun 29, 2008, at 12:46 PM, Andreas Jung wrote: This approach is ugly (because of putting the mapper within the local scope into the global scope (in order to make them importable) and because of thi

[sqlalchemy] Implementation patterns for initializing the model and obtaining the mappers

2008-06-29 Thread Andreas Jung
I am coming from the Zope world and implemented a SA integration layer z3c.sqlalchemy. It basically provides a 'wrapper' exposing a thread-local session as property and as a registry for mappers that can be accessed through a getMapper(mapper_name) method. Now with the declarative layer I am tr

[sqlalchemy] Re: text

2008-06-11 Thread Andreas Jung
--On 11. Juni 2008 17:55:44 +0100 King Simon-NFHD78 <[EMAIL PROTECTED]> wrote: -Original Message- From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of jack2318 Sent: 11 June 2008 17:50 To: sqlalchemy Subject: [sqlalchemy] text I tried very simple test: s =

[sqlalchemy] Re: Using SQLAlchemy with Plone/Zope

2008-05-16 Thread Andreas Jung
--On 16. Mai 2008 18:06:46 +0200 Andreas Jung <[EMAIL PROTECTED]> wrote: --On 16. Mai 2008 08:58:38 -0700 Mike <[EMAIL PROTECTED]> wrote: Hi, We are using SQLAlchemy 4.X in Zope using SQLAlchemyDA, found here: http://opensource.zopyx.com/projects/SQLAlchemyDA This uses

[sqlalchemy] Re: Using SQLAlchemy with Plone/Zope

2008-05-16 Thread Andreas Jung
--On 16. Mai 2008 08:58:38 -0700 Mike <[EMAIL PROTECTED]> wrote: Hi, We are using SQLAlchemy 4.X in Zope using SQLAlchemyDA, found here: http://opensource.zopyx.com/projects/SQLAlchemyDA This uses SA 0.4.0. We are connecting to MS SQL 2000. While this works in Zope for normal SQL commands,

[sqlalchemy] Re: can I set the really default value ?

2008-03-30 Thread Andreas Jung
--On 31. März 2008 01:25:48 +0800 "张沈鹏(电子科大 毕/就业倒计时...)" <[EMAIL PROTECTED]> wrote: I just mean default value in the create table's sql . such as CREATE TABLE xxx ( id INTEGER NOT NULL, value INTEGER default 0 ) Table(..., default=xxx) -aj pgpR3GBJhaQEH.pgp Description: PGP si

[sqlalchemy] Re: Problems connecting to Postgresql using collective.lead

2008-01-19 Thread Andreas Jung
--On 18. Januar 2008 15:56:02 -0800 Alex Turner <[EMAIL PROTECTED]> wrote: I am getting an error connecting to Postgresql: ImportError: unknown database 'psycopg' The canonical driver name for Postgres databases is 'postgres'. Looks like a typo in Martin's book. psycopg(2) is name of the

[sqlalchemy] Re: Filter by year in datetime column

2008-01-18 Thread Andreas Jung
--On 18. Januar 2008 12:08:46 -0500 Rick Morrison <[EMAIL PROTECTED]> wrote: There are no generic date functions in SQLAlchemy (although work has begun on them). So for now, you'll need to use date functions native to your database. For sqlite something like, func.strftime('%Y', Mikrop

[sqlalchemy] SA 0.3.11 producing wrong code for func.any()

2008-01-07 Thread Andreas Jung
Hi, running SA 0.3.11 against PG 7.4. A SA query like session.query(Node).query(func.any(Node.c.tools=='1234') produces the following SQL code: select from node where where any(node.tools) = '1234'. However Postgres does not support this syntax and complains with a syntax error. Postgr

[sqlalchemy] Re: [Postgres/SA 0.3.X] Support for arrays?

2008-01-02 Thread Andreas Jung
--On 2. Januar 2008 11:11:20 -0500 Michael Bayer <[EMAIL PROTECTED]> wrote: On Jan 2, 2008, at 2:56 AM, Andreas Jung wrote: I have a PG table containing a row tools varchar(256)[][] that stores a list of tuples ('HI1234', 'somestring'). Setting the tool

[sqlalchemy] [Postgres/SA 0.3.X] Support for arrays?

2008-01-01 Thread Andreas Jung
I have a PG table containing a row tools varchar(256)[][] that stores a list of tuples ('HI1234', 'somestring'). Setting the tools property on Python level leads to bad SQL code: ProgrammingError) Fehler »syntax error« bei »,« at character 52 'UPDATE hierarchies SET tools=%(tools)s WHERE hier

[sqlalchemy] Re: Modelling connected trees

2008-01-01 Thread Andreas Jung
--On 30. Dezember 2007 18:02:13 -0500 Michael Bayer <[EMAIL PROTECTED]> wrote: I am using this model since some years for the application (hand- made Python code/SQL queries) but now I want to adopt it to SA. The basic question is how I would extend the configuration for the self-referenti

[sqlalchemy] Modelling connected trees

2007-12-30 Thread Andreas Jung
Hi, I habe a table where we store tree-ish data using a self-referential mapper (same setup as within the SA docs using an id for the nodes and a pointer back to the parent node given by its id)...this works without a problem. Now comes the tricky part: a node from one tree can point to a node w

[sqlalchemy] Re: Readonly objects/protecting objects from modifications

2007-12-21 Thread Andreas Jung
--On 21. Dezember 2007 16:33:34 -0500 Michael Bayer <[EMAIL PROTECTED]> wrote: On Dec 21, 2007, at 3:13 PM, Rick Morrison wrote: I think the only way something like this should be done is as a test fixture which decorates classes during unit tests.It would be fairly clumsy to have

[sqlalchemy] Readonly objects/protecting objects from modifications

2007-12-21 Thread Andreas Jung
Is there a way to protect objects from modifications? I have a complex self-referential data structure that is passed to some other modules written by co-workers. I need to avoid that the data structure is changed (because of programming errors). Is there an easy way to accomplish this (other t

[sqlalchemy] Re: SQLAlchemy 0.4 beta5 (OperationalError) database table is locked '\nDROP TABLE os' () sqlite 3.4.2

2007-09-16 Thread Andreas Jung
--On 14. September 2007 10:07:27 -0700 jason kirtland <[EMAIL PROTECTED]> wrote: jean-marc pouchoulon wrote: helo, I don't understand why my sqlite database is locked on a drop ( the code is following) thanks for your explanation. > [...snip...] ordinateurs = computers_table.select(com

[sqlalchemy] Re: "where"-based UPDATEs with ORM?

2007-09-08 Thread Andreas Jung
--On 8. September 2007 08:14:50 -0700 Adam Atlas <[EMAIL PROTECTED]> wrote: I feel like I must be missing something obvious here, but is it possible to do in-database batch UPDATEs with "WHERE" clauses using the ORM/session API? Like, sess.query(User).filter(User.first_name == 'Mackenzie').fi

[sqlalchemy] [SA 0.4] Getting a mapper class from a mapper class

2007-08-14 Thread Andreas Jung
I've been using the following code for obtaining a mapper class from some other mapper. class_mapper(self.__class__).props[name].mapper.class 'props' is no longer available however I found '_Mapper__props'. Is this the right replacement or is there a smarter way? Andreas pgpLkaS4WLfE3.pgp Des

[sqlalchemy] Re: query date field

2007-07-06 Thread Andreas Jung
--On 6. Juli 2007 23:27:30 + jose <[EMAIL PROTECTED]> wrote: I've got a question that I can't find the answer to. I have a table called seminars with a date field in it to hold the seminar dates. I want to query the table to find all the dates for a specific year. I tried query(Seminars

[sqlalchemy] Re: SA trying to update read-only views in Postgres

2007-07-06 Thread Andreas Jung
--On 6. Juli 2007 11:15:38 -0400 Michael Bayer <[EMAIL PROTECTED]> wrote: On Jul 6, 2007, at 6:25 AM, Andreas Jung wrote: I have a self-referential mapper where a view is involved within a primaryjoin of a relation. Traversing a tree represented through the mapper generates a bu

[sqlalchemy] Re: SA trying to update read-only views in Postgres

2007-07-06 Thread Andreas Jung
Clear()ing the session before the mandatory commit resolved the issue (more a workaround than a solution :->). Andreas --On 6. Juli 2007 12:25:25 +0200 Andreas Jung <[EMAIL PROTECTED]> wrote: I have a self-referential mapper where a view is involved within a primaryjoin of a

[sqlalchemy] SA trying to update read-only views in Postgres

2007-07-06 Thread Andreas Jung
I have a self-referential mapper where a view is involved within a primaryjoin of a relation. Traversing a tree represented through the mapper generates a bunch of UPDATE operations on the view (no idea why so far) although only SELECT operations are used during the query. However views in Pos

[sqlalchemy] Re: Mapper based on a select generates wrong and unnecessary INSERTs

2007-07-02 Thread Andreas Jung
--On 2. Juli 2007 14:22:06 + Michael Bayer <[EMAIL PROTECTED]> wrote: On Jul 2, 8:39 am, Andreas Jung <[EMAIL PROTECTED]> wrote: So why the hell is SA trying to insert something into my 'zielgruppen' table? any table in your SELECT statement for which its f

[sqlalchemy] Mapper based on a select generates wrong and unnecessary INSERTs

2007-07-02 Thread Andreas Jung
I have a case where SA 0.3.8 create wrong SQL code and an unneeded and unwanted INSERT statement. My code inserts a new Arbeitsmittel into the DB using: Arbeitsmittel = wrapper.getMapper('arbeitsmittel') d = {'hidx' : hidx, 'zodb_path' : zodb_path, 'versionsnr' : 0,

[sqlalchemy] Re: How to lock using sqlalchemy

2007-06-29 Thread Andreas Jung
At least the select() method has an optional parameter 'lockmode'. You might check the docs and the release notes. -aj --On 29. Juni 2007 08:23:16 + mc <[EMAIL PROTECTED]> wrote: Hi, I need to lock a table for WRITE. The scenario is that I have a SELECT followed by an INSERT, where the IN

[sqlalchemy] Re: Group by? Still a problem

2007-06-27 Thread Andreas Jung
--On 27. Juni 2007 12:00:13 -0700 voltron <[EMAIL PROTECTED]> wrote: I´m guessing a bit because I still could not find the group_by entry in the docs This works: user.select(links.c.id> 3, order_by=[user.c.id]).execute() but this does not user.select(links.c.id> 3,group_by=[user.c.dept]).e

[sqlalchemy] Re: Group by?

2007-06-27 Thread Andreas Jung
--On 27. Juni 2007 06:47:37 -0700 voltron <[EMAIL PROTECTED]> wrote: How can I construct the clause "group by" using SQL construction? By using the group_by parameter of the select() method? -aj pgpiPCUwENlRm.pgp Description: PGP signature

[sqlalchemy] Checking for number of related items

2007-06-19 Thread Andreas Jung
I have a mapper defined as mapper(HierNode, HierTable, properties={ 'tools' : relation(ToolNode), }) Usually I am interested in iterating over all 'tools' and lazy loading works fine. However sometimes I need to determine if one HierNode has tools or not. Loading all tools would be too e

[sqlalchemy] Re: [RESOLVED]Re: SA returning indentical instances for distinct rows.

2007-06-15 Thread Andreas Jung
--On 15. Juni 2007 16:09:32 +0200 Andreas Jung <[EMAIL PROTECTED]> wrote: --On 15. Juni 2007 09:46:27 -0400 Michael Bayer <[EMAIL PROTECTED]> wrote: On Jun 15, 2007, at 3:19 AM, Andreas Jung wrote: Bug or feature? I cant speak authoritatively here at all since youve

[sqlalchemy] Re: SA returning indentical instances for distinct rows.

2007-06-15 Thread Andreas Jung
--On 15. Juni 2007 09:46:27 -0400 Michael Bayer <[EMAIL PROTECTED]> wrote: On Jun 15, 2007, at 3:19 AM, Andreas Jung wrote: Bug or feature? I cant speak authoritatively here at all since youve given me no information about your schema, ive no idea what AMH_View represent

[sqlalchemy] Re: Sequences

2007-06-15 Thread Andreas Jung
--On 15. Juni 2007 12:55:43 + voltron <[EMAIL PROTECTED]> wrote: Could someone point me to the documentation about declaring and using Sequence fields in Sqlalchemy? Check yourself with the SA docs on sqlalchemy.org under "defining sequences". -aj pgpWMRtJ1NwMS.pgp Description: PGP

[sqlalchemy] SA returning indentical instances for distinct rows.

2007-06-15 Thread Andreas Jung
Hi, I have a self-referential mapper that looks like that. Basicially a tree of 'HierarchyNode' where the leafs are 'ArbeitsmittelHierarchyNode' (accessed through the '_tools' property) mapper(HierarchyNode, HierarchyTable, properties={ '_children' : relation( Hi

[sqlalchemy] Re: engine.base._convert_key() fails with long col names

2007-06-14 Thread Andreas Jung
--On 14. Juni 2007 14:13:47 -0400 Michael Bayer <[EMAIL PROTECTED]> wrote: On Jun 14, 2007, at 9:16 AM, Andreas Jung wrote: This happens when _convert_key() is called with key='arbeitsmittelhierarchy_arbeitsmittel_view.stammdatenverwaltung_ta uglich' im confused.

[sqlalchemy] engine.base._convert_key() fails with long col names

2007-06-14 Thread Andreas Jung
From: Andreas Jung <[EMAIL PROTECTED]> To: sqlalchemy@googlegroups.com Subject: engine.base._convert_key() fails with long col names Date-Sent: 14. Juni 2007 15:14:37 Hi, I am getting the following traceback * Module toolbox.product.export_bauplan2, line 96, in export_bauplan *

[sqlalchemy] Re: [MySQL] Checking if commit() is available

2007-06-08 Thread Andreas Jung
--On 8. Juni 2007 14:05:39 -0400 Rick Morrison <[EMAIL PROTECTED]> wrote: try: t.commit() except: print 'Holy cow, this database is lame' This code is also lame :-) The code should work for arbitrary DSNs and swallowing an exception while committing is evil, evil, evil. -aj pgp

[sqlalchemy] [MySQL] Checking if commit() is available

2007-06-08 Thread Andreas Jung
is there a way to determine if the underlying MySQL DB is able to perform a commit() operation? The following code fails (likely because the underlying MySQL db is pretty old, V3ish). Andreas -- dsn = 'mysql://' e = create_engine(dsn) c=e.connect() t = c.begin() t.commit() Tr

[sqlalchemy] Re: stress tests / multithreading on SQLAlchemy 0.3.6

2007-05-27 Thread Andreas Jung
--On 27. Mai 2007 23:45:43 -0700 Alchemist <[EMAIL PROTECTED]> wrote: @Andreas Jung What SA configurations did you set/unset for your Zope application? Nothing special. I am using my own z3c.sqlalchemy framework (Google, search on Cheeseshop). Which SA files should I modify in

[sqlalchemy] Re: stress tests / multithreading on SQLAlchemy 0.3.6

2007-05-27 Thread Andreas Jung
--On 27. Mai 2007 23:27:30 -0700 Alchemist <[EMAIL PROTECTED]> wrote: I developed my web application in TurboGears 1.0.1 (Python 2.4, CherryPy 2.2.1 and SQLAlchemy 0.3.6) and used Postgresql 8.2 as my backend. Also, I am using psycopg2. I am running stress tests (using tools such as WAPT an

[sqlalchemy] Re: cascade='all, delete-orphan' causing error about unsaved, pending instances

2007-05-17 Thread Andreas Jung
--On 17. Mai 2007 02:17:22 -0700 Glauco <[EMAIL PROTECTED]> wrote: Try this: don't use files = [] files.append(vf) but use directly parent mapper: medium.versions[0].files.append( vf ) This won't solve my problem. I rewrote parts of the code in the following way: version =

[sqlalchemy] Re: cascade='all, delete-orphan' causing error about unsaved, pending instances

2007-05-17 Thread Andreas Jung
--On 17. Mai 2007 10:16:17 +0200 Andreas Jung <[EMAIL PROTECTED]> wrote: --On 16. Mai 2007 13:45:21 -0400 Michael Bayer <[EMAIL PROTECTED]> wrote: This code causes the trouble. There is no save() operation involved - just a flush() operation driven by the Zope transaction in

[sqlalchemy] Re: Problem with using global metadata/connection in a threaded context

2007-05-17 Thread Andreas Jung
--On 17. Mai 2007 00:28:35 +0200 David Anderson <[EMAIL PROTECTED]> wrote: I am guessing that somewhere in the mix the engine information is severed from the metadata when jumping to the other thread, but I have no idea how to fix this problem. Can anyone give me pointers on how to get my th

[sqlalchemy] Re: cascade='all, delete-orphan' causing error about unsaved, pending instances

2007-05-17 Thread Andreas Jung
--On 16. Mai 2007 13:45:21 -0400 Michael Bayer <[EMAIL PROTECTED]> wrote: new to the FAQ: http://www.sqlalchemy.org/trac/wiki/ FAQ#FlushError:instancesomeinstanceisanunsavedpendinginstanceandisanorph an The FAQ does not explain the problem. Look at the real code: def importImagesF

[sqlalchemy] cascade='all, delete-orphan' causing error about unsaved, pending instances

2007-05-16 Thread Andreas Jung
I am building a media database using SA where the model basically maps Medium --1:N--> Versions --1:N--> Files My code for creating new Medium instances based on an import script basically is doing the following: f = File(...) v = Version() v.files.append(f) m = Medium() m.versions.append(

[sqlalchemy] Re: Getting hold of a mapper class from within another mapper class?

2007-05-13 Thread Andreas Jung
--On 12. Mai 2007 11:22:51 -0400 Michael Bayer <[EMAIL PROTECTED]> wrote: ok, you mean a "mapped" class, right ? i.e.the History class. i dont exactly understand why you cant just say "History", so heres the most generic way possible to go from 'self' to the class used on a relation: Ba

[sqlalchemy] Getting hold of a mapper class from within another mapper class?

2007-05-12 Thread Andreas Jung
I have the following (scary) use-case: Table 'media' has 1 : N relationship to table 'history'. class Media(object): def addHistory(self, comment): self.history.append(History())) Inside addHistory() I need to get hold of the mapper class History for 'history' in order to append a

[sqlalchemy] Duplicating a row?

2007-05-09 Thread Andreas Jung
Hi, what is the common pattern to duplicate a row? I have several cases where I obtain a row and need to insert it with some slightly modifications back into the table. I've written a small copy method for that but it is ugly code. What's the common way to do that? Andreas pgpOYYmiHG4WV.pgp

[sqlalchemy] [ANN] z3c.sqlalchemy 1.0.0 released - Integration of SQLAlchemy with Zope 2/3

2007-05-06 Thread Andreas Jung
.6 or higher Installation: = - either download z3c.sqlalchemy from Cheeseshop <http://cheeseshop.python.org/pypi/z3c.sqlalchemy/> - or use easy_install: easy_install z3c.sqlalchemy Andreas Jung -- ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübinge

[sqlalchemy] type_code/introspection the types of a ResultProxy

2007-05-01 Thread Andreas Jung
ResultProxy_instance.cursor.description returns the 7-tuple as defined in the Python DB API containing information about the result set. The type_code (the second element of each tuple) is an integer: (('id', 20, 5, 8, None, None, None), ('idgattung', 23, 2, 4, None, None, None), ('bezeichnung

[sqlalchemy] Re: Executing SQL directly inside a thread local transaction?

2007-04-30 Thread Andreas Jung
--On 30. April 2007 19:34:41 + Ian Charnas <[EMAIL PROTECTED]> wrote: Yes! While most *any* query can be done using sqlalchemy... and you *should* try to use sqlalchemy because then if you change databases you won't have to go through all your code and figure out if any of the sql is dif

[sqlalchemy] Executing SQL directly inside a thread local transaction?

2007-04-30 Thread Andreas Jung
I have a scenario where we I need to execute SQL directly within a transaction that is local to a Python thread. Is there some way to this in SA? In this particular usecase there is no UOW involved. Or is it somehow to pass a SQL statement somehow to the session and its underlaying framework? A

[sqlalchemy] Informations about the connection state

2007-04-30 Thread Andreas Jung
Hi, I am currently working on a deeper integration of SA into Zope 2. Is it possible to determine if an engine has open connections to a database? Is it possible to close all connections? This is necessary since a database adapter in Zope can be switched off in order to close connections (e.g.

[sqlalchemy] Re: sqlalchemy introspection How?

2007-04-28 Thread Andreas Jung
--On 28. April 2007 09:00:36 -0700 johnny <[EMAIL PROTECTED]> wrote: What I was trying to get was, there isn't a python command line option, that will create Object Mapper Classes for the tables, What should that be? so I can import them within my applications. I guess, I have to code th

[sqlalchemy] Re: sqlalchemy introspection How?

2007-04-27 Thread Andreas Jung
--On 27. April 2007 12:57:06 -0700 johnny <[EMAIL PROTECTED]> wrote: Does this create a Object Mappers for those tables, so I can do the following: Lets say I have a table called "user" with columns "user_name" and "password". ed = User() ed.user_name = 'Ed' ed.password = 'edspassword' Yo

[sqlalchemy] Re: sqlalchemy introspection How?

2007-04-27 Thread Andreas Jung
--On 27. April 2007 07:02:39 -0700 johnny <[EMAIL PROTECTED]> wrote: I have tables created using another orm. I just want to know, how I can create sqlalchemy classes based on the tables, that are already there in the database? Table('sometable', BoundMetaData(engine), autoload=True) -aj

[sqlalchemy] Re: RESOLVED Re: Generated slow JOIN sql statement/specifying a left JOIN

2007-04-26 Thread Andreas Jung
I resolved this issue. Choosing a different mapper class as first arg of the relation() call solved this issue and everything is working perfectly. -aj --On 26. April 2007 08:44:22 +0200 Andreas Jung <[EMAIL PROTECTED]> wrote: --On 25. April 2007 07:13:19 -0400 Michael Bayer &

[sqlalchemy] Re: Generated slow JOIN sql statement/specifying a left JOIN

2007-04-25 Thread Andreas Jung
--On 25. April 2007 07:13:19 -0400 Michael Bayer <[EMAIL PROTECTED]> wrote: well i just noticed youre sticking an external table into your primaryjoinbut i see nothing there that implies the usage of a LEFT OUTER JOIN ? are you saying that you dont need the rows from AMH_View to be prese

[sqlalchemy] Re: Generated slow JOIN sql statement/specifying a left JOIN

2007-04-24 Thread Andreas Jung
--On 24. April 2007 08:54:55 -0400 Michael Bayer <[EMAIL PROTECTED]> wrote: On Apr 24, 2007, at 4:27 AM, Andreas Jung wrote: Because both tables are big the query takes forever. Using a LEFT JOIN would definitely be faster. Is there a way to configure the 'tools' prope

[sqlalchemy] Generated slow JOIN sql statement/specifying a left JOIN

2007-04-24 Thread Andreas Jung
Hi, I have a self-referential table 'hierarchy' which has a 1:N relationship with a view 'arbeitsmittelhierarchy_arbeitsmittel_view'. They are defined as follows: # generate a mapper of the self-referential table 'hierarchy' HierarchyTable = Table('hierarchy', metadata,

[sqlalchemy] Could not assemble any primary key columns for mapped table error for views

2007-04-23 Thread Andreas Jung
I have a view arbeitsmittelhierarchy_arbeitsmittle_view which is defined as a left join of two tables. Trying to generate a mapper from the autoload view as Table() fails: File "build/bdist.linux-i686/egg/sqlalchemy/orm/session.py", line 277, in query File "build/bdist.linux-i686/egg/sqlalch

[sqlalchemy] Re: ValueError: second must be in 0..59 error?

2007-04-22 Thread Andreas Jung
--On 23. April 2007 08:18:54 +0200 Andreas Jung <[EMAIL PROTECTED]> wrote: Additional info: using SA 0.3.6, Postgres 7.4.6, psycopg 2.0.4 Andreas File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 971, in fetchall ValueError: second must be in 0..59 Any id

[sqlalchemy] Re: ValueError: second must be in 0..59 error?

2007-04-22 Thread Andreas Jung
Additional info: using SA 0.3.6, Postgres 7.4.6, psycopg 2.0.4 Andreas --On 23. April 2007 08:09:30 +0200 Andreas Jung <[EMAIL PROTECTED]> wrote: During a select() I get the following error: 2007-04-23 08:02:24,447 INFO sqlalchemy.engine.base.Engine.0x..94 {'table': 24892275

  1   2   >