[sqlalchemy] Re: query date field

2007-07-07 Thread Andreas Jung



--On 6. Juli 2007 23:27:30 + jose [EMAIL PROTECTED] wrote:



I've got a question that I can't find the answer to.  I have a table
called seminars with a date field in it to hold the seminar dates.  I
want to query the table to find all the dates for a specific year. I
tried query(Seminars).filter(Seminars.c.date.year==2007) but this gave
me an error stating that the col does not have a year property.  So
how should I do this?
Jose




func.to_char(table.c.date, '') == '2007'

or by using between(table.c.date, datetime(2007,1,1) , datetime(2007,31, 
12)) or something like that...


-aj

pgpML11WJE8sW.pgp
Description: PGP signature


[sqlalchemy] Re: query date field

2007-07-07 Thread Mike Orr

On 7/6/07, Andreas Jung [EMAIL PROTECTED] wrote:


 --On 6. Juli 2007 23:27:30 + jose [EMAIL PROTECTED] wrote:

 
  I've got a question that I can't find the answer to.  I have a table
  called seminars with a date field in it to hold the seminar dates.  I
  want to query the table to find all the dates for a specific year. I
  tried query(Seminars).filter(Seminars.c.date.year==2007) but this gave
  me an error stating that the col does not have a year property.  So
  how should I do this?
  Jose
 


  func.to_char(table.c.date, '') == '2007'

 or by using between(table.c.date, datetime(2007,1,1) , datetime(2007,31,
 12)) or something like that...

Or func.year(table.c.date) == 2007


-- 
Mike Orr [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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: How many objects are in a session

2007-07-07 Thread klaus

And when I am at it (this is going off topic): What do you think about
len(query) in addition to or instead of query.count()? IMO, count() is
nearly as SQLish als select().

Best regards
  Klaus


On Jul 6, 3:20 pm, klaus [EMAIL PROTECTED] wrote:
 I noticed that Session has no method len. Wouldn't it be useful to add
 one, like this:

 --- orm/session.py  2007-07-06 14:38:22.0 +0200
 +++ orm/session.py.orig 2007-07-06 14:43:48.0 +0200
 @@ -642,6 +642,9 @@
  def __iter__(self):
  return iter(list(self.uow.new) +
 self.uow.identity_map.values())

 +def __len__(self):
 +return len(self.uow.new) + len(self.uow.identity_map)
 +
  def _get(self, key):
  return self.identity_map[key]

 Then, one could flush() and clear() it if it grows too large.
 (Generally, I think any class with __iter__ should have __len__ too.)

 Best regards
   Klaus


--~--~-~--~~~---~--~~
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: new Engine document

2007-07-07 Thread Neil Blakey-Milner

On 7/6/07, Michael Bayer [EMAIL PROTECTED] wrote:
 I just wrote this but haven't had time to carefully proof it...if
 people have corrections / comments let me know.

I think this is a lot easier to understand - thanks and well done.

Neil
-- 
Neil Blakey-Milner
http://nxsy.org/
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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: new Engine document

2007-07-07 Thread Michael Bayer

i edited further, and its now the normal doc on the site.

one thing I completely spaced on, is i got explcit / implicit
wrong.  the way im using these terms now (i.e. in the book), are:

explicit:
connection.execute(statement)

explicit connectionless:
engine.execute(statement)

implicit (implies connectionless):
statement.execute()


On Jul 7, 5:31 am, Neil Blakey-Milner [EMAIL PROTECTED] wrote:
 On 7/6/07, Michael Bayer [EMAIL PROTECTED] wrote:

  I just wrote this but haven't had time to carefully proof it...if
  people have corrections / comments let me know.

 I think this is a lot easier to understand - thanks and well done.

 Neil
 --
 Neil Blakey-Milnerhttp://nxsy.org/
 [EMAIL PROTECTED]


--~--~-~--~~~---~--~~
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: query date field

2007-07-07 Thread Michael Bayer

heh...youve both answered correctly ...based on the databases you
happen to be using (oracle, mysql).

unfortanately we dont yet have a layer of function abstraction that
smooths over differences like these.  theres a ticket in place in trac
but its awaiting a volunteer for now.

On Jul 7, 5:03 am, Mike Orr [EMAIL PROTECTED] wrote:
 On 7/6/07, Andreas Jung [EMAIL PROTECTED] wrote:





  --On 6. Juli 2007 23:27:30 + jose [EMAIL PROTECTED] wrote:

   I've got a question that I can't find the answer to.  I have a table
   called seminars with a date field in it to hold the seminar dates.  I
   want to query the table to find all the dates for a specific year. I
   tried query(Seminars).filter(Seminars.c.date.year==2007) but this gave
   me an error stating that the col does not have a year property.  So
   how should I do this?
   Jose

   func.to_char(table.c.date, '') == '2007'

  or by using between(table.c.date, datetime(2007,1,1) , datetime(2007,31,
  12)) or something like that...

 Or func.year(table.c.date) == 2007

 --
 Mike Orr [EMAIL PROTECTED]


--~--~-~--~~~---~--~~
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: No update in cascade

2007-07-07 Thread Michael Bayer



On Jul 7, 9:39 am, Koen Bok [EMAIL PROTECTED] wrote:
 And you were right. It turned out to be a stupid idea anyway. Let that
 be a lesson for the next programmer who tries to be lazy ;-)

oh, funny.  i was expecting to hear the use case you had which needs
it.  so are you just setting it manually then ?



--~--~-~--~~~---~--~~
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: Idea for 0.4: URI params / create_engine arguments

2007-07-07 Thread Paul Johnston

Hi,

do you mean, the URI would have args that are used by the DBAPI *or*
the dialect ?  right now, all query strings in the URI go to the
DBAPI's connect() method.   mixing them up I fear opens the door for
name conflicts.  what if some DBAPI were suddenly supported that had a
connect() argument called echo ?
  

Ah, is the current idea that URI parameters are passed to the DBAPI, and 
dialects should use create_engine args?

If that's the intention, I understand your concerns about nameclashes. 
Actually, if that is the case, MSSQL is doing things slightly wrong and 
using URI params where we shouldn't be. This would raise an issue for me 
though - how do you control create_engine parameters for the unit tests?

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: Idea for 0.4: URI params / create_engine arguments

2007-07-07 Thread Michael Bayer



On Jul 7, 10:06 am, Paul Johnston [EMAIL PROTECTED] wrote:

 If that's the intention, I understand your concerns about nameclashes.
 Actually, if that is the case, MSSQL is doing things slightly wrong and
 using URI params where we shouldn't be. This would raise an issue for me
 though - how do you control create_engine parameters for the unit tests?

take a look at test/testbase.py.  for DBAPI query args, they can be in
the query string sent to --dburi.  for other create_engine() args, we
generally support them as explicit options accepted by testbase.py
(such as postgres --serverside cursors)


--~--~-~--~~~---~--~~
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: Idea for 0.4: URI params / create_engine arguments

2007-07-07 Thread Paul Johnston

Hi,

take a look at test/testbase.py.  for DBAPI query args, they can be in
the query string sent to --dburi.  for other create_engine() args, we
generally support them as explicit options accepted by testbase.py
(such as postgres --serverside cursors)  

I see, guess we need to add a couple of MSSQL options there; the dbapi 
springs to mind.

At the moment MSSQL has three URI params that only affect the dialect; 
they are not passed down to the DBAPI. From what you've said, I guess we 
should look at moving these to being parameters to create_engine. 
Perhaps we can make both work in 0.3.9, with a deprecation warning if 
you use the URI. Then in 0.4 we can drop support for the URI. Let me 
know what you think of this - I'll proceed if you reckon it's a good idea.

Looks like you're having a busy week-end coding! All the best,

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: query date field

2007-07-07 Thread Jose Galvez

Thanks, everyone for the pointers.  Since func is not database agnostic,
I think I'll make my own functions in my database module that simply use
func so if I ever do switch form mysql to something else at least I'll
know where to find all the stuff that needs changing
Jose

jose wrote:
 I've got a question that I can't find the answer to.  I have a table
 called seminars with a date field in it to hold the seminar dates.  I
 want to query the table to find all the dates for a specific year. I
 tried query(Seminars).filter(Seminars.c.date.year==2007) but this gave
 me an error stating that the col does not have a year property.  So
 how should I do this?
 Jose


 

   

--~--~-~--~~~---~--~~
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: Future of migrate project

2007-07-07 Thread Evan Rosson

 Yes, a certain level of frustration is bound to occur after you have
 spent an hour reading about the project, downloading the code and
 setting up an example - only to find a show stopping bug, report it
 some time later after finding the right bug tracker... to then notice
 that there hasn't been a check-in for some months and to then have to
 spend a further 15 minutes checking various places to try and find
 it's status.

Sorry about that. There's a warning on migrate's front page now.

--~--~-~--~~~---~--~~
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: Idea for 0.4: URI params / create_engine arguments

2007-07-07 Thread Michael Bayer


On Jul 7, 2007, at 11:32 AM, Paul Johnston wrote:


 Hi,

 take a look at test/testbase.py.  for DBAPI query args, they can  
 be in
 the query string sent to --dburi.  for other create_engine() args, we
 generally support them as explicit options accepted by testbase.py
 (such as postgres --serverside cursors)

 I see, guess we need to add a couple of MSSQL options there; the dbapi
 springs to mind.

 At the moment MSSQL has three URI params that only affect the dialect;
 they are not passed down to the DBAPI. From what you've said, I  
 guess we
 should look at moving these to being parameters to create_engine.
 Perhaps we can make both work in 0.3.9, with a deprecation warning if
 you use the URI. Then in 0.4 we can drop support for the URI. Let me
 know what you think of this - I'll proceed if you reckon it's a  
 good idea.


its fine with me, you and Rick can decide how you want to do that.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---