[sqlalchemy] Re: generate_series?

2008-04-26 Thread Luke Iannini

On Apr 25, 8:46 am, Michael Bayer [EMAIL PROTECTED] wrote:
 On Apr 25, 2008, at 9:04 AM, Luke Iannini wrote:





  Hi all,
  Is there a way to use generate_series with SQLAlchemy?

 http://www.postgresql.org/docs/8.2/interactive/functions-srf.html

  generate_series = select([column('i')],
     from_obj=[func.generate_series(bindparam('start'),
  bindparam('end'))])

  zrows = select([generate_series.params(start=1,
  end=20).c.i]).label('series')

  is the best stab I've made at it, but I don't actually understand the
  syntax in the PGSQL docs:

  select current_date + s.a as dates from generate_series(0,14,7) as
  s(a);

 that particular syntax is an aliasing syntax that we plan on  
 supporting in the near future, so the above would look possibly like

 s = func.generate_series(4,5,6).alias(cols=['a'])

 select([func.current_date() + s.c.a])

 you can hardwire this stuff using text right now:

 select([(func.current_date() +  
 literal_column
 (s.a)).label(dates)]).select_from(generate_series(0, 14, 7) as  
 s(a))
Thanks so much Michael!  That worked perfectly.

 I just noticed that the text() construct, which would allow the  
 bindparams to happen, is not being accepted into select_from() so i've  
 added ticket  #1014 for that.

  As a side question, how would I add static columns to a select
  statement? e.g. based on the pseudocode above:
  zrows = select([generate_series.params(start=1, end=20).c.i], 0, 0,
  0).label('series')
  to add 3 columns of 0 value to each row generated.

 you should be able to put plain strings in the columns clause:

 select([foo, bar, bat])

 this is shorthand for using the literal_column() construct which you  
 can use anywhere in a column expression to produce textual SQL  
 expressions.
Got it. Thanks again

Cheers
Luke

--~--~-~--~~~---~--~~
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: generate_series?

2008-04-26 Thread Luke Iannini

Hm, yes, so is:

Traceback (most recent call last):
  File /Users/LukeIannini/Checkout/trunk/adpinion_web/
HistoryAlchemy.py, line 46, in module
allstats = union_all(stats, zeros)
  File /Library/Python/2.5/site-packages/SQLAlchemy-0.4.1-py2.5.egg/
sqlalchemy/sql/expression.py, line 498, in union_all
return _compound_select('UNION ALL', *selects, **kwargs)
  File /Library/Python/2.5/site-packages/SQLAlchemy-0.4.1-py2.5.egg/
sqlalchemy/sql/expression.py, line 780, in _compound_select
return CompoundSelect(keyword, *selects, **kwargs)
  File /Library/Python/2.5/site-packages/SQLAlchemy-0.4.1-py2.5.egg/
sqlalchemy/sql/expression.py, line 2895, in __init__
self.oid_column = self._proxy_column(s.oid_column)
  File /Library/Python/2.5/site-packages/SQLAlchemy-0.4.1-py2.5.egg/
sqlalchemy/sql/expression.py, line 3323, in oid_column
oid = f.oid_column
AttributeError: '_TextFromClause' object has no attribute 'oid_column'

when trying to union_all the result of a (on its own, seemingly
working) generate_series select a manifestation of the bug you
mentioned or am I doing something else wrong?

Cheers
Luke

On Apr 25, 11:39 pm, Luke Iannini [EMAIL PROTECTED] wrote:
 On Apr 25, 8:46 am, Michael Bayer [EMAIL PROTECTED] wrote:

  On Apr 25, 2008, at 9:04 AM, Luke Iannini wrote:

   Hi all,
   Is there a way to use generate_series with SQLAlchemy?

  http://www.postgresql.org/docs/8.2/interactive/functions-srf.html

   generate_series = select([column('i')],
      from_obj=[func.generate_series(bindparam('start'),
   bindparam('end'))])

   zrows = select([generate_series.params(start=1,
   end=20).c.i]).label('series')

   is the best stab I've made at it, but I don't actually understand the
   syntax in the PGSQL docs:

   select current_date + s.a as dates from generate_series(0,14,7) as
   s(a);

  that particular syntax is an aliasing syntax that we plan on  
  supporting in the near future, so the above would look possibly like

  s = func.generate_series(4,5,6).alias(cols=['a'])

  select([func.current_date() + s.c.a])

  you can hardwire this stuff using text right now:

  select([(func.current_date() +  
  literal_column
  (s.a)).label(dates)]).select_from(generate_series(0, 14, 7) as  
  s(a))

 Thanks so much Michael!  That worked perfectly.



  I just noticed that the text() construct, which would allow the  
  bindparams to happen, is not being accepted into select_from() so i've  
  added ticket  #1014 for that.

   As a side question, how would I add static columns to a select
   statement? e.g. based on the pseudocode above:
   zrows = select([generate_series.params(start=1, end=20).c.i], 0, 0,
   0).label('series')
   to add 3 columns of 0 value to each row generated.

  you should be able to put plain strings in the columns clause:

  select([foo, bar, bat])

  this is shorthand for using the literal_column() construct which you  
  can use anywhere in a column expression to produce textual SQL  
  expressions.

 Got it. Thanks again

 Cheers
 Luke
--~--~-~--~~~---~--~~
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: problems with py2app

2008-04-26 Thread Koen Bok

Hey Iain,

If you build apps with py2app it tries to figure out which modules to
include automatically. If these modules are nested in some weird way
it sometimes chokes. A solution is to import that module by hand in
your main script (your-app-name.py) or telling py2app it needs to add
the module in the setup dict (see manual).

Good luck!

Koen - madebysofa.com

On Apr 26, 7:53 am, iain duncan [EMAIL PROTECTED] wrote:
 Hi folks, I seem to be having a problem with sqlalchemy and py2app, but
 I am very new to OS X and py2app, so I could be doing something stupid.
 When we try to build the app we get this:

 ImportError: No module named logging
 Traceback (most recent call last):
    File
 /Users/bear/iain/booking-wx/dist/booking_main.app/Contents/Resources/__boo 
 t__.py,
 line 137, in module
      _run('booking_main.py')
    File
 /Users/bear/iain/booking-wx/dist/booking_main.app/Contents/Resources/__boo 
 t__.py,
 line 134, in _run
      execfile(path, globals(), globals())
    File
 /Users/bear/iain/booking-wx/dist/booking_main.app/Contents/Resources/booki 
 ng_main.py,
 line 10, in module
      from model_extern import *
    File model_extern.pyc, line 15, in module
    File sqlalchemy/__init__.pyc, line 29, in module
    File sqlalchemy/engine/__init__.pyc, line 54, in module
    File sqlalchemy/engine/base.pyc, line 16, in module
    File sqlalchemy/logging.pyc, line 35, in module
 ImportError: No module named logging
 2008-04-25 22:43:27.066 booking_main[457] booking_main Error
 2008-04-25 22:43:27.067 booking_main[457] booking_main Error
 An unexpected error has occurred during execution of the main script

 I'm not import logging, and the only other libraries being used are
 wxPython and formencode. wx is working ok.

 Any tips or even stories of success/failure would be much appreciated!
 Thanks
 Iain
--~--~-~--~~~---~--~~
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] cant update mssql table

2008-04-26 Thread adi

hi all,
just started out with SA,here is my problem
a table in a mssql db with a uniqueidentifier field as primary key and
an integer field as identity,i am able to insert a row into the table
but not update it ,on updation it gives cannot update identity column.
how do i solve this ,is there a way so that SA does not put a value in
this column and let the database value prevail.
Any help will be great

TIA

--~--~-~--~~~---~--~~
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] cannot update mssql table

2008-04-26 Thread adi

hi all
i am a newbie with SA this is the problem i am having one table with
an uniqueidentfier as PK and an identity field,
i can insert new records but on delete i get cannot update identity
field.How do i bypass this ? is there a way to tell SA not to update
that field or let it pick a default value from the db.


any pointers to what i am doing wrong.

TIA
adi

--~--~-~--~~~---~--~~
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] cant update table in mssqldb

2008-04-26 Thread adi

hi all,
i am a newbie at SA ,te problem i am facing is as follows
i have one table with among other fields one uniqueidentifier field as
primary key and an auto increment identity field although i can insert
new records when i try to update i get cant update identity field
error .How do i avoid this is there a way that SA doesnt pass a value
for that field so that the field gets a default value from the db.
also i forgot mention that all the tables are being created via
reflection.

any pointers/ideas will be extremly helpful


TIA

--~--~-~--~~~---~--~~
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: generate_series?

2008-04-26 Thread Michael Bayer

OK r4566 of trunk also allows text() within select_from(), so you can  
use textual  bind params (denoted by a colon ':'):

generate_series = text(generate_series(:x, :y, :z) as s(a))

s = select([(func.current_date() +  
literal_column(s.a)).label(dates)]).select_from(generate_series)

# load up some parameters:

s = s.params(x=5, y=6, z=7)



--~--~-~--~~~---~--~~
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: problems with py2app

2008-04-26 Thread iain duncan

On Sat, 2008-26-04 at 05:04 -0700, Koen Bok wrote:
 Hey Iain,
 
 If you build apps with py2app it tries to figure out which modules to
 include automatically. If these modules are nested in some weird way
 it sometimes chokes. A solution is to import that module by hand in
 your main script (your-app-name.py) or telling py2app it needs to add
 the module in the setup dict (see manual).
 
 Good luck!
 
 Koen - madebysofa.com

Thanks! Can you tell from that traceback whether it is a module in SA
called logging or whether SA is trying to import the python core logging
module?

Iain

 
 On Apr 26, 7:53 am, iain duncan [EMAIL PROTECTED] wrote:
  Hi folks, I seem to be having a problem with sqlalchemy and py2app, but
  I am very new to OS X and py2app, so I could be doing something stupid.
  When we try to build the app we get this:
 
  ImportError: No module named logging
  Traceback (most recent call last):
 File
  /Users/bear/iain/booking-wx/dist/booking_main.app/Contents/Resources/__boo 
  t__.py,
  line 137, in module
   _run('booking_main.py')
 File
  /Users/bear/iain/booking-wx/dist/booking_main.app/Contents/Resources/__boo 
  t__.py,
  line 134, in _run
   execfile(path, globals(), globals())
 File
  /Users/bear/iain/booking-wx/dist/booking_main.app/Contents/Resources/booki 
  ng_main.py,
  line 10, in module
   from model_extern import *
 File model_extern.pyc, line 15, in module
 File sqlalchemy/__init__.pyc, line 29, in module
 File sqlalchemy/engine/__init__.pyc, line 54, in module
 File sqlalchemy/engine/base.pyc, line 16, in module
 File sqlalchemy/logging.pyc, line 35, in module
  ImportError: No module named logging
  2008-04-25 22:43:27.066 booking_main[457] booking_main Error
  2008-04-25 22:43:27.067 booking_main[457] booking_main Error
  An unexpected error has occurred during execution of the main script
 
  I'm not import logging, and the only other libraries being used are
  wxPython and formencode. wx is working ok.
 
  Any tips or even stories of success/failure would be much appreciated!
  Thanks
  Iain
  


--~--~-~--~~~---~--~~
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: problems with py2app

2008-04-26 Thread az

well, read that traceback...

sqlalchemy/logging.py, line 35:

# py2.5 absolute imports will fix
logging = __import__('logging')

py2app is tracking import xxx' but cannot do __import__() etc 
lowlevel funcs. u have to give it the python's logging module.


On Saturday 26 April 2008 21:01:15 iain duncan wrote:
 On Sat, 2008-26-04 at 05:04 -0700, Koen Bok wrote:
  Hey Iain,
 
  If you build apps with py2app it tries to figure out which
  modules to include automatically. If these modules are nested in
  some weird way it sometimes chokes. A solution is to import that
  module by hand in your main script (your-app-name.py) or telling
  py2app it needs to add the module in the setup dict (see manual).
 
  Good luck!
 
  Koen - madebysofa.com

 Thanks! Can you tell from that traceback whether it is a module in
 SA called logging or whether SA is trying to import the python core
 logging module?

 Iain

  On Apr 26, 7:53 am, iain duncan [EMAIL PROTECTED] wrote:
   Hi folks, I seem to be having a problem with sqlalchemy and
   py2app, but I am very new to OS X and py2app, so I could be
   doing something stupid. When we try to build the app we get
   this:
  
   ImportError: No module named logging
   Traceback (most recent call last):
  File
   /Users/bear/iain/booking-wx/dist/booking_main.app/Contents/Res
  ources/__boo t__.py, line 137, in module
_run('booking_main.py')
  File
   /Users/bear/iain/booking-wx/dist/booking_main.app/Contents/Res
  ources/__boo t__.py, line 134, in _run
execfile(path, globals(), globals())
  File
   /Users/bear/iain/booking-wx/dist/booking_main.app/Contents/Res
  ources/booki ng_main.py, line 10, in module
from model_extern import *
  File model_extern.pyc, line 15, in module
  File sqlalchemy/__init__.pyc, line 29, in module
  File sqlalchemy/engine/__init__.pyc, line 54, in module
  File sqlalchemy/engine/base.pyc, line 16, in module
  File sqlalchemy/logging.pyc, line 35, in module
   ImportError: No module named logging
   2008-04-25 22:43:27.066 booking_main[457] booking_main Error
   2008-04-25 22:43:27.067 booking_main[457] booking_main Error
   An unexpected error has occurred during execution of the main
   script
  
   I'm not import logging, and the only other libraries being used
   are wxPython and formencode. wx is working ok.
  
   Any tips or even stories of success/failure would be much
   appreciated! Thanks
   Iain

 


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