[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

[sqlalchemy] SA 0.8.0 UnicodeDecodeError with Postgres 9.1.9

2013-04-19 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

[sqlalchemy] Re: SA 0.8.0 UnicodeDecodeError with Postgres 9.1.9

2013-04-19 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 UnicodeDecodeError after

[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

[sqlalchemy] XX and YY are both of the same direction symbol 'ONETOMANY 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

[sqlalchemy] Re: session of an object

2009-03-25 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

[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}.} The result format does not

[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 li...@zopyx.com: -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

[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) # 用户ID

[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: 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] 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

[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

[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

[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

[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 table? Usecase: I have one big table (60 cols

[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. While the migration worked for a bigger application I have

[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 I

[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 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(): d = self.__dict__.copy() for k in d.keys

[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, is there some more efficient way for dictifying a resultset other than lst = list

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

2008-12-16 Thread Andreas Jung
), and the stack 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 simple table 'fassung' Toolbox2=# \d fassung

[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] 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] 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] 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

[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 lock all

[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(): Storage RDBMSStorage ATDocument at front-page ab23df631c18ea2c9ae7be8321f647dd 2008-11-23 15:13:39 ERROR root Exception

[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 Zope). Any idea

[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] 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

[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 this code within

[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: 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

[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',

[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.

[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 tools property on Python level leads

[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

[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

[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

[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

[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 =

[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

[sqlalchemy] Re: query date field

2007-07-07 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

[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 relation

[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 bunch

[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

[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

[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

[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(

[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] 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 represents, but AFAICT

[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 given me

[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 * Module

[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. are you passing

[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()

[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

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

2007-05-28 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 and

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

2007-05-28 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 order

[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

[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

[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 integration of SA

[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()

[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

[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
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übingen - Germany Web

[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

[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?

[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

[sqlalchemy] Re: sqlalchemy introspection How?

2007-04-28 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' You might

[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

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

2007-04-26 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

[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 [EMAIL PROTECTED

[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' property in a smarter

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

2007-04-23 Thread Andreas Jung
During a select() I get the following error: 2007-04-23 08:02:24,447 INFO sqlalchemy.engine.base.Engine.0x..94 {'table': 24892275} class 'z3c.sqlalchemy.mapper._mapped_arbeitsmittel' 2007-04-23 08:02:24,480 INFO sqlalchemy.engine.base.Engine.0x..94 SELECT arbeitsmittel.idsachgebiet AS

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

2007-04-23 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} class

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

2007-04-23 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 idea where

[sqlalchemy] Calling SQL directly through a Session instance?

2007-03-25 Thread Andreas Jung
I know that it is possible to pass a SQL statement directly to engine.execute(). Is there a similar API for executing q SQL statement through a Session instance? Andreas pgpYtd9cx8rNT.pgp Description: PGP signature

[sqlalchemy] Re: Eager loading self referential mapper

2007-03-23 Thread Andreas Jung
--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-loading. Is this not yet integrated in SQLAlchemy or theoratically impossible or impractical? Do you really want to load a possibly

[sqlalchemy] Dealing with uncommited data

2007-03-20 Thread Andreas Jung
In a traditional application you can insert a new row and read the row within the same transaction. What is the typical usage pattern to deal with this in SA? In our particular setup (Zope) a new session is created for each new HTTP request and flushed automatically at the end of request when

[sqlalchemy] [Postgres] BIT support?

2007-03-09 Thread Andreas Jung
Hi, are there any plans to support the BIT type of Postgres? Andreas pgp5Z1roj65VK.pgp Description: PGP signature

[sqlalchemy] table.tometadata() not working with UNIQUE constraints

2007-02-17 Thread Andreas Jung
I have a Table instance with a UniqueConstraint. SA fails while creating a copy of the table using table.tometadata(). Is there a workaround? Andreas - Traceback (most recent call last): File schema.py, line 77, in ? M.createTables() File schema.py, line 35, in createTables

[sqlalchemy] Probleming specifying a schema for Table() and using relations

2007-02-04 Thread Andreas Jung
I am getting the following error when defining a one-to-many relationship using the following code: db = create_engine('postgres://postgres:[EMAIL PROTECTED]/eCommerce') metadata = BoundMetaData(db) mapperFactory = MapperFactory(metadata) ProductAward, ProductAwardTable =