[sqlalchemy] Re: Model to Dictionary

2007-07-24 Thread King Simon-NFHD78
What do you mean by a model? If you are talking about an instance of a mapped class, you could try something like this (untested): def model_to_dict(instance): model_dict = {} for propname in instance.mapper.props: model_dict[propname] = getattr(instance, propname) return

[sqlalchemy] Connection initialization

2007-07-24 Thread Paul Colomiets
Hi, How can I place some initialization code for each connection in the pool? Currently I do something like this: engine.execute(SET collation_connection=utf8_general_ci) engine.execute(SET names utf8) engine.execute(SET character_set_client=utf8) engine.execute(SET

[sqlalchemy] MSSQL Time

2007-07-24 Thread Christophe de VIENNE
Hi, The mssql database does not provide a Time or a Date type, but only datetime and smalldatetime. In SQLAlchemy, the smalldatetime is used to implement the generic type Date, but the Time type is not implemented. Is there a particular reason for that ? could it inherit the DateTime type, with

[sqlalchemy] Re: MSSQL Time

2007-07-24 Thread Paul Johnston
Hi Christophe, No particular reason, just no-one has needed it yet, and the unit tests don't cover it. If you want to have a go at a patch, that'd be great. Otherwise I'll take a look at this in the next few days. Paul Christophe de VIENNE wrote: Hi, The mssql database does not provide a

[sqlalchemy] Using SA to move data between databases

2007-07-24 Thread Paul Johnston
Hi, I am migrating an Access database to MSSQL server. I have coded up basic Access support for SQLAlchemy, which I'll be commiting to the 0.4 branch shortly. Using autocode, I now have a set of SQLAlchemy table definitions. My question is: what's a good way to move all the data across?

[sqlalchemy] Re: MSSQL Time

2007-07-24 Thread Christophe de VIENNE
Hi Paul, Thanks, I will give it a try. Stay tuned :-) Christophe 2007/7/24, Paul Johnston [EMAIL PROTECTED]: Hi Christophe, No particular reason, just no-one has needed it yet, and the unit tests don't cover it. If you want to have a go at a patch, that'd be great. Otherwise I'll take

[sqlalchemy] Re: MSSQL Time

2007-07-24 Thread Paul Johnston
Hi, Is there any special condition for the unittests to run on mssql ? A few... you really need to be running on Windows and using PyODBC. And then append ?text_as_varchar=1 to your DBURI. Looking at your command line, it looks like you're running from Unix. You can use PyMSSQL from Unix,

[sqlalchemy] Re: MSSQL Time

2007-07-24 Thread Christophe de VIENNE
2007/7/24, Paul Johnston [EMAIL PROTECTED]: Hi, Is there any special condition for the unittests to run on mssql ? A few... you really need to be running on Windows and using PyODBC. And then append ?text_as_varchar=1 to your DBURI. I'll try that :-) Looking at your command line, it

[sqlalchemy] Re: Using SA to move data between databases

2007-07-24 Thread Christophe de VIENNE
Hi, I'm in the same process, and very interested in the answer ! One idea I had is to define an universal dump format, (based for example on pytables), which could be used to backup and restore datas from/to various databases. If this way is a good one and a good implementation proposed, it

[sqlalchemy] Consistency with DB while modifying metadata

2007-07-24 Thread Anton V. Belyaev
Hey, I believe there is a common approach to the situation, but I just dont know it. Let say, I have some tables created in the DB using SQLAlchemy. Then I modify Python code, which describes the table (add a column, remove another column,...). What is the common way to handle this situation? I

[sqlalchemy] Re: Consistency with DB while modifying metadata

2007-07-24 Thread svilen
On Tuesday 24 July 2007 16:22:43 Anton V. Belyaev wrote: Hey, I believe there is a common approach to the situation, but I just dont know it. Let say, I have some tables created in the DB using SQLAlchemy. Then I modify Python code, which describes the table (add a column, remove another

[sqlalchemy] Cumulative Select

2007-07-24 Thread Koen Bok
I need to do a cumulative select on postgres, and I got it to work with some extreme SQL query, but I was wondering if it could be done more easily without having to drop to SQL but with SQLAlchemy statements. Let's say I have a table with stock transactions like this: Transaction id

[sqlalchemy] Re: Using SA to move data between databases

2007-07-24 Thread michael
On Tue, 24 Jul 2007 15:14:52 +0200 Christophe de VIENNE [EMAIL PROTECTED] wrote: Hi, I'm in the same process, and very interested in the answer ! One idea I had is to define an universal dump format, (based for example on pytables), which could be used to backup and restore datas

[sqlalchemy] Re: Consistency with DB while modifying metadata

2007-07-24 Thread Anton V. Belyaev
On 24 июл, 17:34, svilen [EMAIL PROTECTED] wrote: On Tuesday 24 July 2007 16:22:43 Anton V. Belyaev wrote: Hey, I believe there is a common approach to the situation, but I just dont know it. Let say, I have some tables created in the DB using SQLAlchemy. Then I modify Python

[sqlalchemy] Re: Consistency with DB while modifying metadata

2007-07-24 Thread Michael Bayer
On Jul 24, 2007, at 9:59 AM, Anton V. Belyaev wrote: Of course db modification is hard. It cant be done completely automatically. For now I would like SQLAlchemy just to signal somehow when its definitions are different from already existing db tables. When I do create_all() it checks

[sqlalchemy] Re: How to use SessionContextExt with cherrypy?

2007-07-24 Thread Michael Bayer
theres multiple levels of issues with this. one is, its not very clean to move objects between databases using sessions. to do so, you have to remove the _instance_key of the object and save it into the other session: f = Foo() sess1.save(f) sess1.flush() sess1.expunge(f) del

[sqlalchemy] Re: Consistency with DB while modifying metadata

2007-07-24 Thread svilen
On Tuesday 24 July 2007 17:30:27 Michael Bayer wrote: such a feature would make usage of table reflection, and then a comparison operation, along the lines of : ... assert t.compare(t2) yes i was hoping for such method (:-) And the best will be if it can produce a list/ hierarchy of

[sqlalchemy] Re: Using SA to move data between databases

2007-07-24 Thread Christophe de VIENNE
Hi 2007/7/24, michael [EMAIL PROTECTED]: On Tue, 24 Jul 2007 15:14:52 +0200 Christophe de VIENNE [EMAIL PROTECTED] wrote: Hi, I'm in the same process, and very interested in the answer ! One idea I had is to define an universal dump format, (based for example on pytables),

[sqlalchemy] Re: Consistency with DB while modifying metadata

2007-07-24 Thread Michael Bayer
On Jul 24, 2007, at 11:07 AM, svilen wrote: On Tuesday 24 July 2007 17:30:27 Michael Bayer wrote: such a feature would make usage of table reflection, and then a comparison operation, along the lines of : ... assert t.compare(t2) yes i was hoping for such method (:-) And the best

[sqlalchemy] Re: How to use SessionContextExt with cherrypy?

2007-07-24 Thread Michael Bayer
On Jul 24, 2007, at 12:09 PM, alex.schenkman wrote: class Session(object): def __init__(self, name): self.db = create_engine( 'sqlite:///%s' % name ) self.db.echo = False self.metadata = BoundMetaData(self.db) self.session = create_session()

[sqlalchemy] Re: Using SA to move data between databases

2007-07-24 Thread michael
On Tue, 24 Jul 2007 17:52:55 +0200 Christophe de VIENNE [EMAIL PROTECTED] wrote: Hi 2007/7/24, michael [EMAIL PROTECTED]: On Tue, 24 Jul 2007 15:14:52 +0200 Christophe de VIENNE [EMAIL PROTECTED] wrote: Hi, I'm in the same process, and very interested in the answer !

[sqlalchemy] Re: Consistency with DB while modifying metadata

2007-07-24 Thread svilen
assert t.compare(t2) yes i was hoping for such method (:-) And the best will be if it can produce a list/ hierarchy of differences, which then programaticaly can be iterated - and checked and resolved or raised higher. but why not just use autoload=True across the board in the

[sqlalchemy] Re: Cumulative Select

2007-07-24 Thread Michael Bayer
I had to put one little trick in here to make the subquery - something work, which is something i should look into; otherwise it went straight in. from sqlalchemy import * transaction = table('transaction', column('id'), column('id_product'), column('price'),

[sqlalchemy] Re: Cumulative Select

2007-07-24 Thread Koen Bok
And again you made my day... On Jul 24, 7:17 pm, Michael Bayer [EMAIL PROTECTED] wrote: I had to put one little trick in here to make the subquery - something work, which is something i should look into; otherwise it went straight in. from sqlalchemy import * transaction =

[sqlalchemy] Re: MSSQL Time

2007-07-24 Thread Rick Morrison
The list is useful only for a hacker on the MSSQL module, not for general users, but FWIW, I've added it to http://www.sqlalchemy.org/trac/wiki/DatabaseNotes I generally try to respond directly to help encourage anyone willing to offer a hand on the MSSQL module, as I don't have the time these

[sqlalchemy] Re: MSSQL Time

2007-07-24 Thread sdobrev
On Tuesday 24 July 2007 23:29:52 Rick Morrison wrote: The list is useful only for a hacker on the MSSQL module, not for general users, but FWIW, I've added it to http://www.sqlalchemy.org/trac/wiki/DatabaseNotes thanks I generally try to respond directly to help encourage anyone willing to