[sqlalchemy] Re: Firebird - called a stored procedure which returns a value

2009-08-04 Thread Werner F. Bruhin
Figured out how to run the called procedure. sql = db.sa.text(select trans_value from t(:totrans, :username), bindparams=[db.sa.bindparam('totrans', 'some text orig'), db.sa.bindparam('username', me.name)]) result =

[sqlalchemy] Re: Declarative base and Adjacency List Relationships

2009-08-04 Thread Werner F. Bruhin
Hi, maxi wrote: Hi, I´ve just using sqlalchemy 0.5.1 with python 2.6 and turbogers, but I found a little problem trying to configurate adjacency relationship with declarative base. My object class is something like this: class QueryGroup(DeclarativeBase): __tablename__ =

[sqlalchemy] Re: Firebird - called a stored procedure which returns a value

2009-08-04 Thread Werner F. Bruhin
Michael Bayer wrote: Werner F. Bruhin wrote: Figured out how to run the called procedure. sql = db.sa.text(select trans_value from t(:totrans, :username), bindparams=[db.sa.bindparam('totrans', 'some text orig'), db.sa.bindparam

[sqlalchemy] Firebird - called a stored procedure which returns a value

2009-08-02 Thread Werner F. Bruhin
I can't figure quit figure this out. In an FB admin tool I can do: select * from T('some text orig', 'wbruhin'); or execute procedure T('some text orig', 'wbruhin'); And they return: a varchar some text orig auf Deutsch The following runs without error: ... me = session.query(db.Users).get(1)

[sqlalchemy] Re: how does a class instance find its values

2009-07-25 Thread Werner F. Bruhin
Robert, robert rottermann wrote: ... however I would like to change the assignMyselfToCompany method in a way that I could achieve the same with: product = tblProducts_kl() product.assignMyselfToCompany(company_id) Unless you do some more things in your assignMyselfToCompany I think

[sqlalchemy] Re: Q: fetch value of autoincrement column

2009-05-24 Thread Werner F. Bruhin
Adrian von Bidder wrote: On Friday 22 May 2009 23.00:05 Werner F. Bruhin wrote: What do you want to do with the autoincrement column? Often these are used for primary keys, which in turn get used as foreign keys. I want to use the id as filename; the table will cache some info

[sqlalchemy] Re: Q: fetch value of autoincrement column

2009-05-22 Thread Werner F. Bruhin
Adrian, Adrian von Bidder wrote: Hi, Is it possible to fetch the values of an autoincrement field without flushing the object to the DB? (In postgres, I obviously can manually fetch nextval of the automatically generated sequence, but I lose the portability that way ...) Why?

[sqlalchemy] Re: how to transaction like this

2009-05-20 Thread Werner F. Bruhin
Hi, manman wrote: yes,i known,but how do i do that? if not commit parent,how to get the parent id? flush should be enough, but I think you could also do: assuming you have a relation parent c.parent.append(p) or the other way round p.children.append(c) Werner

[sqlalchemy] Re: puzzling outerjoin in the mapper

2009-05-03 Thread Werner F. Bruhin
Michael Bayer wrote: You need to set allow_null_pks=true on your mapper. This will be on by default in 06. I am running into the same problem, but I use declarative. After some search and looking at mapper.py I figured out I could do this: db.Vcbook.__mapper__.allow_null_pks = True

[sqlalchemy] Re: How to use mappers in a wxPython app?

2009-03-29 Thread Werner F. Bruhin
Opus wrote: Hello, I'm a sqlalchemy newbie and I'm trying to get a handle on how and where to do the mappers in my app. The app consists of a frame split window tree control flat notebook. The idea is that when you click on a node in the tree, the record is opened in a new tab in the

[sqlalchemy] Re: Correct way of moving relation

2009-01-30 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: oh, duh. do it like this: for purchase in list(aItem.purchase): purchase.cbbottle = bItem I leave it to you as an exercise why this is the case. aItem.purchase is an instrumented list and as such is mutable, is that the right conclusion? Thanks

[sqlalchemy] Re: Getting ForeignKey Before Commit

2009-01-30 Thread Werner F. Bruhin
n00b wrote: why don't you work off the las/previous committed rec id? On Jan 29, 4:05 am, Dejan Mayo dejan.m...@gmail.com wrote: Hi, My code is like that: try: for some_val in some_values: rec = SomeModel() rec.some_val = some_val session.save(rec)

[sqlalchemy] Correct way of moving relation

2009-01-29 Thread Werner F. Bruhin
I have some items which are related but I need to change it so they related to another item. Before getting myself in a mess (as I need to do this for a bunch of tables) I wanted to check if the following approach is fine. I am using SA 0.5, ORM and declarative and the model is: class

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread Werner F. Bruhin
Werner F. Bruhin wrote: I have some items which are related but I need to change it so they related to another item. Before getting myself in a mess (as I need to do this for a bunch of tables) I wanted to check if the following approach is fine. I am using SA 0.5, ORM and declarative

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: ... there's no need to reassign the FK column yourself and the original pattern you're using is correct. that only one item in the list is the exception suggests something else is changing its state again further down the road. Thanks for the quick

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread Werner F. Bruhin
Michael, I run the following script and initially had the either my application and/or the IB Expert database tool (for Firebird SQL v 2.1) open at the same time. Now the following tests are done without any other task accessing the database. script: engine = db.sa.create_engine(dburl,

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread Werner F. Bruhin
Michael Bayer wrote: .. right there, purchasid 80 is not even in the list of items anymore. This is basically iterate the list, 80 is there, then flush(), then 80 is not there. this is all before anything has been moved. so either the flush() does something, or just the move of

[sqlalchemy] Re: INSERT ... ON DUPLICATE KEY UPDATE

2009-01-21 Thread Werner F. Bruhin
camlost wrote: hello, i'm trying to use sqlalchemy 0.5.1 with python 2.5.4 on windows. and mysql 5.1. the task is simple: to keep fresh information about our servers. i can get a list of server names from AD, get some info about them and insert them into DB using Session.add(). if i run

[sqlalchemy] Re: how to walk through a query result

2009-01-12 Thread Werner F. Bruhin
Michael, Thanks for the quick reply. Michael Bayer wrote: On Jan 11, 2009, at 4:51 PM, Werner F. Bruhin wrote: I can not find the answer looking through the 0.5 doc for my problem. query = session.query(db.SomeClass).filter(something).order_by(anorder) # get the first row row

[sqlalchemy] how to walk through a query result

2009-01-11 Thread Werner F. Bruhin
I can not find the answer looking through the 0.5 doc for my problem. query = session.query(db.SomeClass).filter(something).order_by(anorder) # get the first row row = query.first() # display a dialog to the user # one of the possible actions is to press a button which should show the next

[sqlalchemy] Re: SQLAlchemy 0.5rc4 Released

2008-11-16 Thread Werner F. Bruhin
Shawn, Shawn Church wrote: On Sat, Nov 15, 2008 at 7:55 AM, Michael Bayer [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: easy_install remains a mystery to me in general. Try easy_install sqlalchemy==0.5.0rc4 , or otherwise yeah delete out your dev versions. I use

[sqlalchemy] Re: SQLAlchemy 0.5rc4 Released

2008-11-15 Thread Werner F. Bruhin
I just easy_install'ed it and got sqlalchemy-0.5.0rc4dev_r0-py2.5.egg Is this the correct one or did my getting the SVN version the other day causes a problem? Werner --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

[sqlalchemy] Re: 0.5.0rc3 - kinterbasdb.ProgrammingError: (0, 'Invalid cursor state. The cursor must be open to perform this operation.')

2008-11-11 Thread Werner F. Bruhin
Michael Bayer wrote: On Nov 10, 2008, at 12:10 PM, Werner F. Bruhin wrote: Michael, Michael Bayer wrote: I know what this is and it should be working in r5280. I don't have access to firebird here so we weren't able to run the tests on it before rc3 was out. Installed

[sqlalchemy] Re: 0.5.0rc3 - kinterbasdb.ProgrammingError: (0, 'Invalid cursor state. The cursor must be open to perform this operation.')

2008-11-10 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: I know what this is and it should be working in r5280. I don't have access to firebird here so we weren't able to run the tests on it before rc3 was out. Thanks for the quick reply. Looking at the changes doc these will be included in rc4 - any idea

[sqlalchemy] 0.5.0rc3 - kinterbasdb.ProgrammingError: (0, 'Invalid cursor state. The cursor must be open to perform this operation.')

2008-11-10 Thread Werner F. Bruhin
I am getting sometimes the following exception with rc3 which I did not see with rc2 when I do something like this: engine = sa.create_engine(dburl, encoding='utf8', echo=False) # connect to the database ##connection = engine.connect() Session = sao.sessionmaker()

[sqlalchemy] Re: connect data base

2008-10-13 Thread Werner F. Bruhin
nano wrote: hello, I'm new to sqlalchemy and database I just installed postgres http://doc.fedora-fr.org/wiki/ Installation_et_configuration_de_PostgreSQL, and I have a problem connecting to my database with a script sqlalchemy the error is

[sqlalchemy] Re: Limit to 500 records after particular date.

2008-09-24 Thread Werner F. Bruhin
Heston, Heston James wrote: Hi, Thanks for the response, that gave me a good foot in the door to this. I've now appened my existing query with. .order_by('myobject.created')[:1000] Just tried this on a simple example: query = query.limit(500) Quote from doc for 0.5rc1: *def

[sqlalchemy] Re: Limit to 500 records after particular date.

2008-09-24 Thread Werner F. Bruhin
Heston, Heston James wrote: Werner, Thank you for your response, very kind of you. This looks to be more what I'm looking for, after a quick test it seems that it is now applying the limit at the SQL level which is definitly a good thing. Where abouts in the documentation did you find

[sqlalchemy] Replacing a Firebird view with orm.query.join

2008-09-12 Thread Werner F. Bruhin
I have a view in an FB db with basically does this CREATE VIEW VCBOOK( CB_CELLARBOOKID, CBV_CBVINTAGEID, CBB_CBBOTTLEID ) AS select cb.cellarbookid, cbv.cbvintageid, cbb.cbbottleid, from cellarbook cb left outer join cbvintage cbv on cb.cellarbookid = cbv.fk_cellarbookid left outer

[sqlalchemy] Re: Replacing a Firebird view with orm.query.join

2008-09-12 Thread Werner F. Bruhin
Still not there, but another question/problem below: Werner F. Bruhin wrote: I have a view in an FB db with basically does this CREATE VIEW VCBOOK( CB_CELLARBOOKID, CBV_CBVINTAGEID, CBB_CBBOTTLEID ) AS select cb.cellarbookid, cbv.cbvintageid, cbb.cbbottleid, from cellarbook

[sqlalchemy] Re: Replacing a Firebird view with orm.query.join

2008-09-12 Thread Werner F. Bruhin
Werner F. Bruhin wrote: ... j3 = sao.outerjoin(db.Cellarbook, db.Cbvintage).outerjoin(db.Cbvintage, db.Cbbottle) print j3 j1 and j2 produce a join clause, but on j3 I get the following exception: I different exception if I actually try to use j3: I do this: wine = session.query

[sqlalchemy] Re: Replacing a Firebird view with orm.query.join

2008-09-12 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: ... if CellarBook, Cbvintage, etc. are mapped classes, the join and outerjoin functions you must be using are from sqlalchemy.orm import join, outerjoin. those are aware of ORM mapped classes whereas sqlalchemy.sql.expression.join/outerjoin are not.

[sqlalchemy] Re: Replacing a Firebird view with orm.query.join

2008-09-12 Thread Werner F. Bruhin
Michael Bayer wrote: ... Now, if you actually want to get back objects for the outerjoins, youd say somehting like: sess.query(SomeClass, SomeOtherClass, SomeThirdClass) On Firebird when I do this I get a cross join (according to the Helen Borrie book) which in my case gives me 280

[sqlalchemy] Re: Replacing a Firebird view with orm.query.join

2008-09-12 Thread Werner F. Bruhin
Michael Bayer wrote: On Sep 12, 2008, at 12:49 PM, Werner F. Bruhin wrote: Michael Bayer wrote: ... Now, if you actually want to get back objects for the outerjoins, youd say somehting like: sess.query(SomeClass, SomeOtherClass, SomeThirdClass) On Firebird when I do

[sqlalchemy] Re: Replacing a Firebird view with orm.query.join

2008-09-12 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: ... OK, more specifically, this is how to do the query: sess.query(SomeClass, SomeOtherClass, SomeThirdClass).outerjoin((SomeOtherClass, SomeClass.foo==SomeOtherClass.bar), (SomeThirdClass, SomeOtherClass.foo==SomeThirdClass.bar)) if firebird can't do

[sqlalchemy] Passive delete problem

2008-09-01 Thread Werner F. Bruhin
I have a problem deleting a Consevent instance and get the exception shown further below. Relevant part of my model: class Consevent(Base): __table__ = sa.Table(u'consevent', metadata, sa.Column(u'conseventid', sa.Integer(), sa.Sequence('gen_consevent_conseventid'), primary_key=True,

[sqlalchemy] Re: Passive delete problem

2008-09-01 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: passive_deletes doesnt prevent SA from operating upon rows which are currently represented in the Session, only from loading in not-already- loaded rows from the databse in order to ensure they are all detached ro removed. Instead, set viewonly=True on

[sqlalchemy] Re: wx and SqlAlchemy

2008-08-29 Thread Werner F. Bruhin
Mike, Mike wrote: I found the issue. For some reason, SqlAlchemy is passing a unicode string to a varchar field in SQL Server, which is causing an error to be raised. If I explicitly set the value to an integer or a string, it works fine. I'm not sure how it's getting cast to unicode,

[sqlalchemy] Re: wx and SqlAlchemy

2008-08-28 Thread Werner F. Bruhin
Mike, Mike wrote: Hi, I am working on a wxPython application that saves data to various tables in our MS SQL Server 2000. I connect to one table and get data using a session. This works great. I then do a session.close() and then a conn.close() where conn = engine.connect(). This seems to

[sqlalchemy] Re: wx and SqlAlchemy

2008-08-28 Thread Werner F. Bruhin
Mike, Sent this a bit to quickly Mike wrote: Hi, I am working on a wxPython application that saves data to various tables in our MS SQL Server 2000. I connect to one table and get data using a session. This works great. I then do a session.close() and then a conn.close() where conn =

[sqlalchemy] Re: Storing UTC Dates

2008-08-28 Thread Werner F. Bruhin
Heston, Heston James - Cold Beans wrote: Hello Guys, This might seem like a bit of a naive question but I’m looking for your advice. Being from the UK we operate on Daylight Savings Time which gives us a one hour offset on times for a few months of the year. I currently have a DateTime

[sqlalchemy] Re: wx and SqlAlchemy

2008-08-28 Thread Werner F. Bruhin
Mike, Mike wrote: ... Does this work for multiple databases? This particular program I am working on will be connecting to 2 or 3 databases and a table or three in each of those. I'm pretty sure I have to create separate engines for each db and probably bind separate sessions for those.

[sqlalchemy] Re: wx and SqlAlchemy

2008-08-28 Thread Werner F. Bruhin
(wx.GetApp().Getds2()) self.theList2.InitObjectListView() when selecting items from theList I display some details and I can update these details and commit. Maybe this helps, but maybe it just causes more confusion? Werner On Aug 28, 10:29 am, Werner F. Bruhin [EMAIL PROTECTED] wrote

[sqlalchemy] Re: db model - default and onupdate problems

2008-08-25 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: On Aug 24, 2008, at 6:42 AM, Werner F. Bruhin wrote: I have this in my model: sa.Column(u'created', sa.Date(), default=sa.func.now()), sa.Column(u'updated', sa.Date(), onupdate=datetime.datetime.now), But the dates don't get updated when I do

[sqlalchemy] db model - default and onupdate problems

2008-08-24 Thread Werner F. Bruhin
I have this in my model: sa.Column(u'created', sa.Date(), default=sa.func.now()), sa.Column(u'updated', sa.Date(), onupdate=datetime.datetime.now), But the dates don't get updated when I do: langtable = [ INSERT INTO LANGUAGE (LANGID, NAME, LOCALES) VALUES (1, 'English', 'en'),

[sqlalchemy] Re: SavePoint question

2008-07-22 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: ... if FB didn't raise an error when you said begin_nested() then i think SAVEPOINT is working. Any number of SAVEPOINTS are still all contained within the larger transaction, though. If you want u3 to be committed regardless of the transaction, you'd have

[sqlalchemy] SavePoint question

2008-07-22 Thread Werner F. Bruhin
I have a similar case to what is shown in the doc, here my slightly different usecase, see the commit for u3 and a final rollback. Session = sessionmaker() sess = Session() sess.add(u1) sess.add(u2) sess.begin_nested() # establish a savepoint sess.add(u3) # in my case this is data I would

[sqlalchemy] How to totally close down db connection?

2008-06-27 Thread Werner F. Bruhin
Within my application (FB SQL) I use kinterbasdb.services to do backup and restore operations. No problem with the backup, but the restore is not working as SA seems to hang on to a connection. I do basically this to connect: self.engine = db.sa.create_engine(dburl, encoding='utf8',

[sqlalchemy] Re: How to totally close down db connection?

2008-06-27 Thread Werner F. Bruhin
Werner F. Bruhin wrote: Within my application (FB SQL) I use kinterbasdb.services to do backup and restore operations. No problem with the backup, but the restore is not working as SA seems to hang on to a connection. I do basically this to connect: self.engine

[sqlalchemy] read only column with declaritive

2008-06-25 Thread Werner F. Bruhin
Michael had helped me in the past to get read only columns defined like this: ## old model non declarative ##class Quality(OrmObject): ##def comboname(self): ##return self._comboname ##comboname = property(comboname) ## ##quality = sao.mapper(Quality, quality_table, ##

[sqlalchemy] Exception when changing to declarative

2008-06-25 Thread Werner F. Bruhin
I am changing my model to using declarative. I am getting an exception bool' object has no attribute '__visit_name__' (full exception below) which was relatively difficult for me to trace down. The bool exception I get when I change this: vrecingrwfit = sao.relation('Vrecingrwfit',

[sqlalchemy] Re: read only column with declaritive - resolved

2008-06-25 Thread Werner F. Bruhin
It looks like I just confused myself, in my test case I got None returned and I thought it was a model definition issue but it was me leaving one of the columns used for the computed column at None. So if I do just the following the read only column (FB SQL computed column) are working for

[sqlalchemy] Re: accessing fields by name

2008-06-25 Thread Werner F. Bruhin
Alex, alex bodnaru wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 hello friends, as opposed to a table.query() that returns a list of records of that table, with fields accessible as record attributes, a select() statement returns a list of tuples with the values of the fields

[sqlalchemy] Re: problem with server_default (and/or sa.PassiveDefault in 0.5.beta1

2008-06-23 Thread Werner F. Bruhin
Svilen and Michael, Thanks for all the pointers. Will look into this all and read up some more on declarative (I like its approach, having things together) and do some more test scripts for my application. Werner Michael Bayer wrote: that __repr__ is pretty tortured too; a typical

[sqlalchemy] Re: problem with server_default (and/or sa.PassiveDefault in 0.5.beta1

2008-06-18 Thread Werner F. Bruhin
I did some more research on this. If I change back to 0.4.3, i.e. change my model to use: ##pkg_resources.require(sqlalchemy) # get latest version pkg_resources.require(sqlalchemy==0.4.3) # use a specific version Then I can debug my code, i.e. my application starts. So, I changed it

[sqlalchemy] Re: problem with server_default (and/or sa.PassiveDefault in 0.5.beta1

2008-06-18 Thread Werner F. Bruhin
Werner F. Bruhin wrote: I did some more research on this. If I change back to 0.4.3, i.e. change my model to use: ##pkg_resources.require(sqlalchemy) # get latest version pkg_resources.require(sqlalchemy==0.4.3) # use a specific version Then I can debug my code, i.e. my application

[sqlalchemy] Re: problem with server_default (and/or sa.PassiveDefault in 0.5.beta1

2008-06-18 Thread Werner F. Bruhin
Michael Bayer wrote: On Jun 18, 2008, at 4:05 AM, Werner F. Bruhin wrote: All other tables (including the full version of preferences) are using metadata = sa.MetaData(), instead of the metadataMin I use for the prefminimal definition. I got this working some month ago, but maybe

[sqlalchemy] problem with server_default (and/or sa.PassiveDefault in 0.5.beta1

2008-06-17 Thread Werner F. Bruhin
I just got beta1 and I run into a problem with the following: sa.Column(u'consumedvalue', sa.Numeric(precision=18, length=2, asdecimal=True), sa.PassiveDefault()), consumedvalue is a readonly column (i.e. computed by Firebird SQL) and I am getting the following exception when I try to

[sqlalchemy] Re: problem with server_default (and/or sa.PassiveDefault in 0.5.beta1

2008-06-17 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: On Jun 17, 1:06 pm, Werner F. Bruhin [EMAIL PROTECTED] wrote: I just got beta1 and I run into a problem with the following: sa.Column(u'consumedvalue', sa.Numeric(precision=18, length=2, asdecimal=True), sa.PassiveDefault()), consumedvalue

[sqlalchemy] Re: app not closing when py2exe'd it

2008-05-28 Thread Werner F. Bruhin
Werner F. Bruhin wrote: Werner F. Bruhin wrote: I am having a problem with my app not closing correctly when I py2exe'd it. Trying to track it down but with not much look so far and as sqlalchemy is one of the big changes I did in this version of the app (i.e. moved from another ORM

[sqlalchemy] app not closing when py2exe'd it

2008-05-25 Thread Werner F. Bruhin
I am having a problem with my app not closing correctly when I py2exe'd it. Trying to track it down but with not much look so far and as sqlalchemy is one of the big changes I did in this version of the app (i.e. moved from another ORM to sqlalchemy) I wonder if there are some things I have

[sqlalchemy] Re: refresh(object)

2008-05-11 Thread Werner F. Bruhin
Micheal, Michael Bayer wrote: ... you need the refresh() to cascade onto the objects present in the vconseventmu collection, so set 'vconseventmu' as sao.relation(Vconseventmu, cascade=save-update, merge, refresh- expire). Thanks that did the trick. Werner

[sqlalchemy] Re: refresh(object)

2008-05-10 Thread Werner F. Bruhin
Michael, Thanks for the quick reply, I needed a bit of time to be able to get some more data on this. Michael Bayer wrote: ... uh it depends on what object.otherviewofsubobject is...is that a relation() ? a python descriptor ? if the latter, how does it work ? where does it get

[sqlalchemy] refresh(object)

2008-05-07 Thread Werner F. Bruhin
I have a problem with refresh, doing something along these lines: object.subobject object.otherviewofsubobject (this is actually a Firebird SQL view - which I use for read only access) do some update to subobject session.flush() refresh(object) object.subobject object.otherviewofsubobject

[sqlalchemy] Re: Entity name None - solved

2008-02-12 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: On Feb 11, 2008, at 12:02 PM, Werner F. Bruhin wrote: Thanks again for you quick reply. I had a case problem, my string was containing the mapper name instead of the object name. not sure if you're referring to your emailthe error basically

[sqlalchemy] Re: Entity name None

2008-02-11 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: ... the entity name part of the message there is only trying to identify which mapper the given object is mapped to. but in this case it looks like you are saving an actual Mapper object (when you should be sending one of your application's object

[sqlalchemy] How to check that orm object is the same

2008-02-06 Thread Werner F. Bruhin
In my wxPython GUI I get an error if I reselect the same object and then issue a commit. I get the exception: InvalidRequestError: Object 'Tastingsys(tastingsysid=5, ..., xmltype=u'GEN100')' is already attached to session '114990800' (this is '63582576') I would like to do something like:

[sqlalchemy] Handling of currency values

2008-02-02 Thread Werner F. Bruhin
I am converting an existing Firebird DB over to use sqlalchemy (0.4.0) and I can't figure out how to define the model for currency values. In the DB they are defined as numeric(18,2) default 0 and in the model I do e.g. sa.Column(u'cbb_currentvalue',

[sqlalchemy] Re: FYI: SQLAutocode 0.4.1 and 0.5 released

2007-11-13 Thread Werner F. Bruhin
Hi Gerhard, Gerhard Haering wrote: On Tue, 13 Nov 2007 06:00:25 -0800, Simon Pamies [EMAIL PROTECTED] wrote: [...] I'm very pleased to announce the release of SQLAutocode 0.4.1 and 0.5. This tool enables SQLAlchemy users to automagically generate python

[sqlalchemy] Firebird engine - support for embedded version

2007-11-12 Thread Werner F. Bruhin
I would like to change SA to support the embedded version of Firebird SQL. I am close but the process does not terminate correctly (i.e. I have to kill it), so I am obviously missing something. I made the following change to firebird.py (SA 0.4.0 final): def create_connect_args(self,

[sqlalchemy] Re: Firebird engine - support for embedded version

2007-11-12 Thread Werner F. Bruhin
Werner F. Bruhin wrote: I would like to change SA to support the embedded version of Firebird SQL. I am close but the process does not terminate correctly (i.e. I have to kill it), so I am obviously missing something. Just noticed that I can also use this: dburl = sa.engine.url.URL

[sqlalchemy] Re: Firebird engine - support for embedded version

2007-11-12 Thread Werner F. Bruhin
Werner F. Bruhin wrote: Werner F. Bruhin wrote: I would like to change SA to support the embedded version of Firebird SQL. I am close but the process does not terminate correctly (i.e. I have to kill it), so I am obviously missing something. Just noticed that I can also use

[sqlalchemy] Re: Firebird engine - support for embedded version

2007-11-12 Thread Werner F. Bruhin
Hi Florent, Florent Aide wrote: On Nov 12, 2007 12:57 PM, Werner F. Bruhin [EMAIL PROTECTED] wrote: Which means firebird.py does not need to be patched, however I still see the same problem that the process hangs. As the version of FB is 2.1beta I wondered if maybe

[sqlalchemy] Re: How to define a column as read-only (e.g. computed by column in Firebird)

2007-11-08 Thread Werner F. Bruhin
Mike, Michael Bayer wrote: ... oh sorry, I misread the source code in SA earlier...for an INSERT, we are going to insert None for all columns that are blank but dont have a default. so your two options here are to put another PassiveDefault on the column:

[sqlalchemy] Re: data inserted by db trigger is not returned when I re-query the row

2007-11-07 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: On Nov 6, 2007, at 12:20 PM, Werner F. Bruhin wrote: I insert a raw into a table and then retrieve again but columns which are filled by a db trigger don't return the updated values. The following is a code snippet and I wonder what I am missing. engine

[sqlalchemy] Re: How to define a column as read-only (e.g. computed by column in Firebird)

2007-11-07 Thread Werner F. Bruhin
Mike, Michael Bayer wrote: On Nov 7, 2007, at 12:32 PM, Werner F. Bruhin wrote: Can you point out what I did wrong, please. id have to see a larger example, seems like something is marking the column as modified when it should not be. I put a little test case together

[sqlalchemy] Re: data inserted by db trigger is not returned when I re-query the row - solved

2007-11-07 Thread Werner F. Bruhin
Werner F. Bruhin wrote: Michael, Michael Bayer wrote: On Nov 6, 2007, at 12:20 PM, Werner F. Bruhin wrote: I insert a raw into a table and then retrieve again but columns which are filled by a db trigger don't return the updated values. The following is a code snippet and I

[sqlalchemy] Re: How to define a column as read-only (e.g. computed by column in Firebird)

2007-11-07 Thread Werner F. Bruhin
Mike, Michael Bayer wrote: On Nov 7, 2007, at 10:23 AM, Werner F. Bruhin wrote: How can I define a column in the table as read-only? I have some computed by columns, e.g.: consumedvalue computed by (quantity*unitprice) These columns can not be updated, otherwise I get the following

[sqlalchemy] How to define a column as read-only (e.g. computed by column in Firebird)

2007-11-07 Thread Werner F. Bruhin
How can I define a column in the table as read-only? I have some computed by columns, e.g.: consumedvalue computed by (quantity*unitprice) These columns can not be updated, otherwise I get the following exception: ProgrammingError: (ProgrammingError) (-151, 'isc_dsql_prepare: \n attempted

[sqlalchemy] Re: data inserted by db trigger is not returned when I re-query the row

2007-11-07 Thread Werner F. Bruhin
Mike, Michael Bayer wrote: On Nov 7, 2007, at 5:19 AM, Werner F. Bruhin wrote: PassiveDefault is great to know. However I still have a problem with the following. In a program I do something like this: botlot3 = session.query(db.Bottaglot).get(39) Then some other user

[sqlalchemy] data inserted by db trigger is not returned when I re-query the row

2007-11-06 Thread Werner F. Bruhin
I insert a raw into a table and then retrieve again but columns which are filled by a db trigger don't return the updated values. The following is a code snippet and I wonder what I am missing. engine = sa.create_engine(url, encoding='utf8', echo=False) Session =

[sqlalchemy] Re: Error determining primary and/or secondary join for relationship

2007-11-03 Thread Werner F. Bruhin
Werner F. Bruhin wrote: ... My problem was that I had two foreign key columns which related to the same table. Initially I didn't see that hint in the exception message. So changing my mapper to include a primaryjoin as follows solved the problem. preferences = sao.mapper(Preferences

[sqlalchemy] Error determining primary and/or secondary join for relationship

2007-11-02 Thread Werner F. Bruhin
I am getting the following exception, but I can't figure out what I specified incorrectly. I have other relations setup which work fine. Appreciate if someone can put me right. File c:\downloaded software\python\sqlalchemy-0.4.0beta6\lib\sqlalchemy\orm\properties.py, line 402, in

[sqlalchemy] Re: SQLalchemy coding style

2007-10-29 Thread Werner F. Bruhin
McA wrote: Hi all, I'm intersted in using sqlalchemy and started to read the manuals. I didn't find a hint for my question, so I'm asking here. I hope it's not too annoying. Most code examples in the documentation use something like this from sqlalchemy. import I

[sqlalchemy] Re: Connecting to a Microsoft Access Database

2007-10-13 Thread Werner F. Bruhin
Eddie, Eddie wrote: Thank your Paul (and Expo!) Just curious but where would I look to find out that I needed to use access instead of mssql? You might want to check the documentation: http://www.sqlalchemy.org/docs/04 More specifically:

[sqlalchemy] Re: FYI: AutoCode moved to a new repository

2007-10-11 Thread Werner F. Bruhin
Simon, Simon Pamies wrote: Hi, although I said I would start on Friday if there are no objections, I couldn't longer resist to revamp autocode and so I moved it to google code. Please have a look at http://code.google.com/p/sqlautocode/ for the changes and the current structure. I also

[sqlalchemy] Re: engine.execute

2007-10-11 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: On Oct 10, 2007, at 5:56 AM, Werner F. Bruhin wrote: Looking at the doc for 0.4 I see that I should be able to do this: result = engine.execute(select username from users) ... do something with the result result.close() But I am getting the following

[sqlalchemy] Re: engine.execute

2007-10-11 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: First of all, thanks for this response. i'd embed the SP call explicitly in the select(): select([table.c.id, table.c.foo, table.c.bar, func.convert_I18n (table.c.data).label('data')]).where(...) if using the ORM, set up the column explicitly:

[sqlalchemy] engine.execute

2007-10-10 Thread Werner F. Bruhin
Looking at the doc for 0.4 I see that I should be able to do this: result = engine.execute(select username from users) ... do something with the result result.close() But I am getting the following exception. Note that I am using Firebird SQL and the firebird.py is the one patched by Roger.

[sqlalchemy] i10n of data

2007-10-08 Thread Werner F. Bruhin
Hi, I wonder if there is a standard in how to deal with i10n data in tables with SA, I have search google and the documentation but without any success. For example one has a table for countries were at least the name has to be translated from e.g. Germany to Deutschland etc., with a Default

[sqlalchemy] Database views

2007-10-05 Thread Werner F. Bruhin
In my existing Firebird database I have some views defined. In the model I thought I could just go ahead and define them basically like tables but I get an exception: Traceback (most recent call last): File saTest.py, line 4, in module import modelTest as model File

[sqlalchemy] Re: Database views

2007-10-05 Thread Werner F. Bruhin
it would be fine.) I'll consider this for the views where I don't have a unique key and/or can't define a composite key with what I already have in there. Thanks Werner On 10/5/07, Werner F. Bruhin [EMAIL PROTECTED] wrote: In my existing Firebird database I have some views defined

[sqlalchemy] blob column - how to define in model

2007-10-04 Thread Werner F. Bruhin
I have just started to work with sqlalchemy and there is one thing I can't figure out. I am using Firebird SQL 2.0 and kinterbasdb 3.2, and I have some blob columns defined as: NOTES MEMO /* MEMO = BLOB SUB_TYPE 1 SEGMENT SIZE 80 */, CREATE DOMAIN MEMO AS BLOB SUB_TYPE 1 SEGMENT

[sqlalchemy] Firebird - column types

2007-10-04 Thread Werner F. Bruhin
Scanning firebird.py I noticed that: FBText returns BLOB SUB_TYPE 2 Shouldn't that be BLOB SUB_TYPE 1 or BLOB SUB_TYPE TEXT and FBBinary returns BLOB SUB_TYPE 1 Shouldn't that be BLOB SUB_TYPE 0 See Helen's FB Book on page 182 and/or page 78 of the IB 6 Data Definition Guide (DataDef.pdf).

[sqlalchemy] Re: blob column - how to define in model

2007-10-04 Thread Werner F. Bruhin
Michael Bayer wrote: On Oct 4, 2007, at 5:07 AM, Werner F. Bruhin wrote: I have just started to work with sqlalchemy and there is one thing I can't figure out. I am using Firebird SQL 2.0 and kinterbasdb 3.2, and I have some blob columns defined as: NOTES MEMO /* MEMO