[sqlalchemy] Re: Multiple inserts and last_inserted_ids

2007-11-25 Thread Michael Bayer


On Nov 25, 2007, at 5:46 PM, Paul Johnston wrote:

>
> Hi,
>
> I just realised, MSSQL is not returning last_inserted_ids correctly  
> when
> an insert is done with multiple sets of params for a single  
> statement. I
> don't think this is particularly a problem, just wanted to check what
> the intention is.
>

executemany() calls aren't supposed to return anything for  
last_inserted_ids.   if you need last_inserted_ids you need to use  
individual insert executions.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Multiple inserts and last_inserted_ids

2007-11-25 Thread Paul Johnston

Hi,

I just realised, MSSQL is not returning last_inserted_ids correctly when 
an insert is done with multiple sets of params for a single statement. I 
don't think this is particularly a problem, just wanted to check what 
the intention is.

Paul

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Running just one unit test

2007-11-25 Thread Michael Bayer

ensure that './test/' is in your PYTHONPATH.


On Nov 25, 2007, at 1:31 PM, Paul Johnston wrote:

>
> Hi,
>
> With Python 2.5 is it possible to run just one unit test? If I try
> running, say, sql/query.py I get "ImportError: No module named  
> testbase"
> presumably this is due to the absolute import path changes.
>
> Any ideas?
>
> Paul
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Polymorphic Mapper with Custom Column Type

2007-11-25 Thread Michael Bayer

youre looking for behavior which changes at the class level, therefore  
you shuldnt use TypeDecorator, you should use a Python property on  
your ReceiveTransaction class.   Since the attribute is inherited, you  
need to redfine the mapped attribute to be named "_quantity" on the  
base mapper first, then put properties on both Deliver and Receieve  
classes to interpret the value appropriately.

On Nov 25, 2007, at 9:01 AM, Koen Bok wrote:

>
> Hi, I am trying to store numeric values for an object inverted in the
> database. For that I created a custom TypeDecorator. It work's fine.
> But I only want to apply it to one inherited object type for that
> object. See example code at: http://paste.pocoo.org/show/12411/
>
> Thanks, Koen
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Running just one unit test

2007-11-25 Thread Paul Johnston

Hi,

With Python 2.5 is it possible to run just one unit test? If I try 
running, say, sql/query.py I get "ImportError: No module named testbase" 
presumably this is due to the absolute import path changes.

Any ideas?

Paul

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: pyodbc and inserts... again

2007-11-25 Thread Paul Johnston

Hi,

>I've just noticed a remaining problem with the pyodbc/inserts with
>triggers/scope_identity()/set nocount on/nextset() thing ;-) (it's
>still a workaround if I understand correctly?)
>  
>
scope_identity is expected to be a permanent solution. The "set nocount 
on" is a bit of a hack and will ideally be removed some day. If you 
comment it out at the moment, it causes 12 additional unit tests 
failures, so a bit of work is needed to do this cleanly.

>new version, which keeps jumping as long as there are errors:
>  
>
Looks good to me, and doesn't cause any additional unit tests to fail. 
Committed in 3819.

Paul

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: unicode support for MSSQL

2007-11-25 Thread Florent Aide

On Nov 25, 2007 6:24 PM, Paul Johnston <[EMAIL PROTECTED]> wrote:
>
> Hi Florent,
>
> Just realised we'd gone quiet on this thread...
>
> >humm What bothers me is that I already get this comportement when
> >running my query program from a Linux host (using pyodbc same version)
> >but need the above mentioned patch on a windows host so there is
> >definitely a different behavior.
> >
> >
> Is this a difference in PyODBC or SQLAlchemy? I suspect the former, but
> good if you can confirm.

the diff is in SA. Please look at my last patch to see why. This is
because the support unicode flag is controlled by the test:
supports_unicode = sys.maxunicode == 65535

and on Linux (mine at least) is equals to false, but on Windows it
equals to True...

my patch makes this flag always false on Windows and then all works as intended

Florent.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: unicode support for MSSQL

2007-11-25 Thread Rick Morrison
If memory serves, there is already an 'encoding' attribute on each Dialect
instance that is normally used in conjunction with another Dialect flag
'convert_unicode'. Not sure if it dovetails with your plans, tho

On 11/25/07, Paul Johnston <[EMAIL PROTECTED]> wrote:
>
>
> Hi Florent,
>
> Just realised we'd gone quiet on this thread...
>
> >humm What bothers me is that I already get this comportement when
> >running my query program from a Linux host (using pyodbc same version)
> >but need the above mentioned patch on a windows host so there is
> >definitely a different behavior.
> >
> >
> Is this a difference in PyODBC or SQLAlchemy? I suspect the former, but
> good if you can confirm.
>
> >>From my point of view I am responsible to give the engine the right
> >encoding when I instantiate it. At the moment I have a master database
> >that provides me this info and so I feed it to the constructor at
> >engine creation time.
> >
> >
> That sounds ok. I'd be happy to add a "string_charset" option or
> something that defaults to None which means no decoding. In fact, this
> wouldn't have to be MSSQL specific, it could apply to any DB.
>
> Paul
>
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Getting quater wise result using date_part

2007-11-25 Thread Paul Johnston

Hi,

>I am using date_part to get data from PostgresSQL  and i want to fetch
>data quarter wise (Q!,Q2,Q3,Q4)
>  
>
I'd use SQL CASE for this, something like (untested):

CASE WHEN MONTH <= 3 THEN 1
WHEN MONTH <= 6 THEN 2
WHEN MONTH <= 9 THEN 3
ELSE 4

When you have this working in SQL, transcribing to SA shouldn't be too hard.

Paul

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: unicode support for MSSQL

2007-11-25 Thread Paul Johnston

Hi Florent,

Just realised we'd gone quiet on this thread...

>humm What bothers me is that I already get this comportement when
>running my query program from a Linux host (using pyodbc same version)
>but need the above mentioned patch on a windows host so there is
>definitely a different behavior.
>  
>
Is this a difference in PyODBC or SQLAlchemy? I suspect the former, but 
good if you can confirm.

>>From my point of view I am responsible to give the engine the right
>encoding when I instantiate it. At the moment I have a master database
>that provides me this info and so I feed it to the constructor at
>engine creation time.
>  
>
That sounds ok. I'd be happy to add a "string_charset" option or 
something that defaults to None which means no decoding. In fact, this 
wouldn't have to be MSSQL specific, it could apply to any DB.

Paul



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Serializing (pickling) a ClauseList

2007-11-25 Thread Michael Bayer

it should pickle just fine, even if youre using func. ...

 >>> from sqlalchemy import *
 >>> cl= expression.ClauseList(expression.column('one'), func.foo())
 >>> import pickle
 >>> pickle.dumps(cl)
"ccopy_reg\n_reconstructor\np0\n(csqlalchemy.sql.expression\nClauseList 
\np1\nc__builtin__\nobject 
\np2\nNtp3\nRp4\n(dp5\nS'operator'\np6\ncsqlalchemy.sql.operators 
\ncomma_op\np7\nsS'clauses'\np8\n(lp9\ng0\n(csqlalchemy.sql.expression 
\n_ColumnClause 
\np10\ng2\nNtp11\nRp12\n(dp13\nS'_is_oid'\np14\nI00\nsS'primary_key'\np15\nI00\nsS'is_literal'\np16\nI00\nsS'foreign_keys'\np17\n(lp18\nsS'key'\np19\nS'one'\np20\nsS'table'\np21\nNsS'type'\np22\ng0\n(csqlalchemy.types\nNullType\np23\ng2\nNtp24\nRp25\n(dp26\nS'_impl_dict'\np27\n(dp28\nsbsS'_ColumnClause__label'\np29\nNsS'name'\np30\ng20\nsbag0\n(csqlalchemy.sql.expression\n_Function\np31\ng2\nNtp32\nRp33\n(dp34\nS'clause_expr'\np35\ng0\n(csqlalchemy.sql.expression\n_Grouping\np36\ng2\nNtp37\nRp38\n(dp39\ng22\nNsS'elem'\np40\ng0\n(g1\ng2\nNtp41\nRp42\n(dp43\ng6\ng7\nsg8\n(lp44\nsS'group'\np45\nI01\nsS'group_contents'\np46\nI01\nsbsbsg45\nI01\nsg30\nS'foo'\np47\nsS'packagenames'\np48\n(lp49\nsS'oid_column'\np50\nNsS'_bind'\np51\nNsg22\ng25\nsbasg45\nI01\nsg46\nI01\nsb."



On Nov 25, 2007, at 9:32 AM, exhuma.twn wrote:

>
> Is it possible to somehow pickle a ClauseList object (output of the
> and_ function for example)?
> I would like to store the "where" part of a query and re-use it later.
> If I simply try to pickle a clause-list, I get some errors, that the
> "now" method cannot be pickled. Which makes sense. But I wonder why
> this is in there anyhow. Where clauses are not bound to time.
>
> I suppose then that this has to do with SLQA-internals. But is there a
> way to somehow store predicates?
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Serializing (pickling) a ClauseList

2007-11-25 Thread exhuma.twn

Is it possible to somehow pickle a ClauseList object (output of the
and_ function for example)?
I would like to store the "where" part of a query and re-use it later.
If I simply try to pickle a clause-list, I get some errors, that the
"now" method cannot be pickled. Which makes sense. But I wonder why
this is in there anyhow. Where clauses are not bound to time.

I suppose then that this has to do with SLQA-internals. But is there a
way to somehow store predicates?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Polymorphic Mapper with Custom Column Type

2007-11-25 Thread Koen Bok

Hi, I am trying to store numeric values for an object inverted in the
database. For that I created a custom TypeDecorator. It work's fine.
But I only want to apply it to one inherited object type for that
object. See example code at: http://paste.pocoo.org/show/12411/

Thanks, Koen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---