[sqlalchemy] Re: pyodbc issues

2009-04-24 Thread Michael Mileusnich
I have formated my PC with Vista 32. I also Installed SQL Server 2008 Express. Installed Python 2.6 and pyodbc...SAME ISSUE. I would be willing to have somebody overlook my python code. With echo on everything looks like it should be INSERTING. On Wed, Apr 22, 2009 at 1:40 AM, Michael

[sqlalchemy] changing a max subquery into sqlalchemy query

2009-04-24 Thread outer_edge
Hi all I'm trying to translate a sql query into sqlalchemy http://www.pylonshq.com/pasties/6eab0a062bdbfe30b7310e5b5714f22e my efforts so far http://www.pylonshq.com/pasties/21753610908db32e133e2925535e9645 just a side note I should have named many_id something better like maintable_id so it

[sqlalchemy] Pre-INSERT/UPDATE and Post-SELECT actions

2009-04-24 Thread Brendan Zerr
I'm just starting out using SQLAlchemy and Pylons. I'm trying to create a model that will hash the 'password' field before insert/update into the database. Basically I'm looking for a way to filter data before it goes in and before it comes out of the database. Here's some snippets: class

[sqlalchemy] Linking Tables using Reflection

2009-04-24 Thread greg
Hello, How do I create a link between two tables (1:1) when using reflection to define my objects? Suppose my database has tables: Table_A id (Integer, primary_key) name (String) Table_B id (Integer, primary_key) shoe_size (VarChar(5)) In my program I do: A = Table('Table_A', metadate,

[sqlalchemy] Re: Pre-INSERT/UPDATE and Post-SELECT actions

2009-04-24 Thread Michael Bayer
the two main options are using TypeDecorator, or to filter at the object level using the technique described at http://www.sqlalchemy.org/docs/05/mappers.html#using-descriptors . On Apr 23, 2009, at 12:51 PM, Brendan Zerr wrote: I'm just starting out using SQLAlchemy and Pylons. I'm

[sqlalchemy] Re: Linking Tables using Reflection

2009-04-24 Thread Michael Bayer
the best way would be that your database uses FOREIGN KEY constraints, which would be reflected. If your tables don't have any, you can express the ForeignKey construct post-reflection as described in http://www.sqlalchemy.org/docs/05/metadata.html#overriding-reflected-columns . as far

[sqlalchemy] Re: changing a max subquery into sqlalchemy query

2009-04-24 Thread Michael Bayer
s = select ([func .max (history .c .history_id ).label('history_id')]).group_by(history.c.many_id).alias('max_history') sess.query(History).join((s, and_(History.history_id==s.c.history_id, History.action_id.in_([foo, bar] examples of using query.join() are illustrated at

[sqlalchemy] Re: pyodbc issues

2009-04-24 Thread Michael Bayer
On Apr 24, 2009, at 4:02 AM, Michael Mileusnich wrote: I have formated my PC with Vista 32. I also Installed SQL Server 2008 Express. Installed Python 2.6 and pyodbc...SAME ISSUE. I would be willing to have somebody overlook my python code. With echo on everything looks like it

[sqlalchemy] Re: pyodbc issues

2009-04-24 Thread Michael Bayer
On Apr 24, 2009, at 9:47 AM, Michael Bayer wrote: On Apr 24, 2009, at 4:02 AM, Michael Mileusnich wrote: I have formated my PC with Vista 32. I also Installed SQL Server 2008 Express. Installed Python 2.6 and pyodbc...SAME ISSUE. I would be willing to have somebody overlook my

[sqlalchemy] Re: changing a max subquery into sqlalchemy query

2009-04-24 Thread fintan
Thanks Michael, your a star. I'll read up over the weekend. fintan. 2009/4/24 Michael Bayer mike...@zzzcomputing.com s = select ([func .max (history .c .history_id ).label('history_id')]).group_by(history.c.many_id).alias('max_history') sess.query(History).join((s,

[sqlalchemy] UnmappedColumnError when using relation on a mapper to arbitrary select

2009-04-24 Thread Ksenia
Hi, I can't find what I am doing wrong here. The relevant parts of code: news = Table('news', dbmeta, autoload=True) news_query = select(columns=[news], whereclause=or_(news.c.blog == None, news.c.blog == False)) mapper(News, news_query, properties={ 'roles':relation(Role,

[sqlalchemy] Re: django middleware or signals for sqlalchemy Session

2009-04-24 Thread Jeff FW
Definitely go with middleware--it's very clean and simple. Also, make sure to use sqlalchemy.orm.scoped_session()--it makes using sessions in Django pretty much transparent; any time you need to work with a session, you call Session(), and it either uses your current one, or creates a new one if

[sqlalchemy] Re: django middleware or signals for sqlalchemy Session

2009-04-24 Thread Etienne Robillard
Hi you can also try out http://gthc.org/projects/notmm/0.2.12/ if you feel adventurous and if you are not afraid of using the pdb to find problems in your very own app, not the django one. althought its clear to me that sometimes the best approach for adding sessions depends on the scope of your

[sqlalchemy] Reflection, Foreign Keys, Auto Defaults, Oh My!

2009-04-24 Thread greg
Hello, Everyone, I'm getting to know SQLAlchemy after watching the PyCon tutorials and have a couple of questions I hope you can either can/will answer for me or point me in the correct direction. I'm using SQLAlchemy v 0.5.3 with Python 2.6 on Windows hitting a SQL Server database. I am using

[sqlalchemy] Re: pyodbc issues

2009-04-24 Thread Michael Mileusnich
yes On Fri, Apr 24, 2009 at 8:47 AM, Michael Bayer mike...@zzzcomputing.comwrote: On Apr 24, 2009, at 4:02 AM, Michael Mileusnich wrote: I have formated my PC with Vista 32. I also Installed SQL Server 2008 Express. Installed Python 2.6 and pyodbc...SAME ISSUE. I would be willing to

[sqlalchemy] Re: Reflection, Foreign Keys, Auto Defaults, Oh My!

2009-04-24 Thread greg
I just noticed that part of this has been answered yesterday. I apologize for the redundancy; I did not think I had posted the earlier request. --greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy

[sqlalchemy] Re: Advice on integrating Alchemy with a caching mechanism such as Shove

2009-04-24 Thread phrrn...@googlemail.com
I wasn't able to achieve what I wanted without mucking around with private methods but the code below does work very nicely with reference tables. The code generator pokes in the log10 rowcount as of the time the schema was sampled (I use log10 so that we don't get a bunch of spurious diffs if a

[sqlalchemy] Re: mapping class against multiple databases

2009-04-24 Thread phrrn...@googlemail.com
I did just that this afternoon to link across heterogeneous dataservers. Modulo the inevitable awkwardness from having two different names for the same thing (i.e. Asset and EjvAsset), this was very easy: class_mapper(Asset).add_properties({ 'EjvAsset' : relation(EjvAsset,

[sqlalchemy] Re: pyodbc issues

2009-04-24 Thread mtrier
On Apr 24, 2009, at 4:02 AM, Michael Mileusnich wrote: I have formated my PC with Vista 32.  I also Installed SQL Server 2008 Express.  Installed Python 2.6 and pyodbc...SAME ISSUE.  I would be willing to have somebody overlook my python code.  With echo on everything looks like it

[sqlalchemy] Changing Python type associated with temporal datatypes without using custom TypeDecorator?

2009-04-24 Thread phrrn...@googlemail.com
My employers have a custom Python type (derived from datetime) for dealing with dates and datetimes.Let's call it 'BananaDate'. They would like BananaDate be used by SQL Alchemy. The standard way of doing this appears to be with a TypeDecorator: class BananaDate(types.TypeDecorator): from

[sqlalchemy] select() ussage

2009-04-24 Thread David Gardner
Recently I had a fairly complex SQL query I wanted to write out using SQLAlchemy. I ended up implementing it using select() so what I end up doing looks something like: parent=my_table.alias('parent') child=my_table.alias('child') j=parent.outerjoin(child, condition) my_qry=select([my_table],

[sqlalchemy] Re: pyodbc issues

2009-04-24 Thread Michael Mileusnich
Mine code looks the same except for: def __init__(self, **kwargs): for my ACTIONS. Should I try emailing pyodbc about this issue? On Fri, Apr 24, 2009 at 3:14 PM, mtrier mtr...@gmail.com wrote: On Apr 24, 2009, at 4:02 AM, Michael Mileusnich wrote: I have formated my PC with Vista

[sqlalchemy] Re: pyodbc issues

2009-04-24 Thread Michael Bayer
Michael Mileusnich wrote: Mine code looks the same except for: def __init__(self, **kwargs): for my ACTIONS. Should I try emailing pyodbc about this issue? if you create a pyodbc test script, not using SQLAlchemy in any way, which performs a plain INSERT and then a commit(), and you have

[sqlalchemy] Re: Changing Python type associated with temporal datatypes without using custom TypeDecorator?

2009-04-24 Thread phrrn...@googlemail.com
My manager came up with a rather clever -- if not devious -- suggestion: implement the type adapators as usual but then diddle the namespace of the package where the SA model is defined. I tried it and it works but is sufficiently confusing that I am now in favor of changing the models so that

[sqlalchemy] Re: pyodbc issues

2009-04-24 Thread Michael Trier
On Apr 24, 2009, at 5:36 PM, Michael Mileusnich justmike2...@gmail.com wrote: Mine code looks the same except for: def __init__(self, **kwargs): for my ACTIONS. Should I try emailing pyodbc about this issue? So does the script work on your system? What's the echo output from it?

[sqlalchemy] Re: pyodbc issues

2009-04-24 Thread Michael Mileusnich
Wow..your example worked for me. Could the kwargs the issue? On Fri, Apr 24, 2009 at 3:14 PM, mtrier mtr...@gmail.com wrote: On Apr 24, 2009, at 4:02 AM, Michael Mileusnich wrote: I have formated my PC with Vista 32. I also Installed SQL Server 2008 Express. Installed Python 2.6

[sqlalchemy] Re: Revers Dialect - SQL Interpreter

2009-04-24 Thread Jarrod Chesney
Hi all again. I have a program that has a UI and allows the user to do some data or metadata manipulations. This is ok if the user (me) wants to make a couple of changes, The changes have to go through my program as has a form of metadata version control in it. This could become quite tedious