[sqlalchemy] Re: Consistency with DB while modifying metadata

2007-07-24 Thread svilen
> i just saw there is some usagerecipe ModelUpdate in the wiki, may > be a good start point: > http://www.sqlalchemy.org/trac/wiki/UsageRecipes/ModelUpdate > and this one: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/AutoCode --~--~-~--~~~---~--~~ You received

[sqlalchemy] Re: Consistency with DB while modifying metadata

2007-07-24 Thread svilen
i just saw there is some usagerecipe ModelUpdate in the wiki, may be a good start point: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/ModelUpdate > > >> 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: 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

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

[sqlalchemy] Re: MSSQL & Time

2007-07-24 Thread sdobrev
> The reasons for the failures that I've had time to look into have > so far had as much to do with the tests as with the MSSQL module. > They are mostly fixable within the constraints that the various > supported MSSQL DBAPI modules impose: > > -- DBLib (required by pymssql) does not like Uni

[sqlalchemy] Re: MSSQL & Time

2007-07-24 Thread Rick Morrison
Hi Christope, > I see. Are the reasons for thoses failures well known ? fixable ? If > it's not too tricky I could spend a bit of time on it in a little > while. The reasons for the failures that I've had time to look into have so far had as much to do with the tests as with the MSSQL module. Th

[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 - > work, which is something i should look into; otherwise it > went straight in. > > from sqlalchemy import * > > transaction = table('tra

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

2007-07-24 Thread Christophe de VIENNE
Hi michael, 2007/7/24, michael <[EMAIL PROTECTED]>: > Hello Christophe, > > If I am reading you intent (and forgive me if I am wrong), you would > like to have one backup/restore routine for the same schema but on a > variety of databases. Yes > And, you want the user to be responsible for > do

[sqlalchemy] Re: Cumulative Select

2007-07-24 Thread Michael Bayer
I had to put one little "trick" in here to make the subquery - 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'), col

[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

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

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

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

2007-07-24 Thread alex.schenkman
Thanks for taking the time to answer this. I have had a frustrating day and this gives me hope again, =) I'm not trying to move objects between sessions. I might be misunderstanding the APIs here, but what I think I need is the following: Two persons surf to my site at the same time and I keep s

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

[sqlalchemy] Re: MSSQL & Time

2007-07-24 Thread Christophe de VIENNE
Hi, I have a working patch which add a MSTime type on mssql. http://www.sqlalchemy.org/trac/attachment/ticket/679 The unittest DateTest runs successfully on my linux box with pymssql, and I'd like somebody to try and run it under windows, as I don't have time to set up a testing env' right now.

[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: 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 f._instan

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

2007-07-24 Thread Michael Bayer
current approach is to use the "creator" keyword to create_engine(), which references a callable that returns a connection. you connect, and then issue whatever additional SQL on the connection before returning it. however this means your URL is just "://" and any additional portions of

[sqlalchemy] How to use SessionContextExt with cherrypy?

2007-07-24 Thread alex.schenkman
Hi: I'm new writing web apps and I'm using cherrypy with sqlalchemy. As I understand it, each user navigating the site and clicking on pages gets a new thread and thus it is necesary to use sqlalchemy in a thread-safe manner. After reading the docs I assume that I have to use SessionContextExt,

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

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

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

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

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

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

[sqlalchemy] Re: MSSQL & Time

2007-07-24 Thread Christophe de VIENNE
Hi, I wrote a little patch for mysql.py that add a MSTime type, but before submitting anything, I'd like the unittest to run run successfully. The problem is that the tests (especially the DateTest) fail with mssql before I touch anything in the code (cf details at the end of the message). Is th

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

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

[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

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

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

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