[sqlalchemy] Re: Could not assemble any primary key columns for mapped table

2007-05-07 Thread ml

That's it, thanks!


Michael Bayer napsal(a):
 
 On May 4, 2007, at 9:17 AM, ml wrote:
 
 Hi!

 I have a few tables with non-integer primary keys. Following raises an
 exception:

 meta = MetaData(name=somemeta)
 themes = table(themes, meta,
 Column(title, Unicode(30), primary_key=True),
   )
 class Theme(object): pass
 mapper(Theme, themes).compile()
 
 youre using the wrong table constructor.  try Table().
 
 
  
 

--~--~-~--~~~---~--~~
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: Multiple tables forming one class?

2007-05-07 Thread Gaetan de Menten

And btw, in case I didn't understand what you wanted and you really
wanted to map one class to several tables, you'll find information
about that there:

http://www.sqlalchemy.org/docs/adv_datamapping.html#advdatamapping_joins

On 5/7/07, Gaetan de Menten [EMAIL PROTECTED] wrote:
 On 5/7/07, Spider [EMAIL PROTECTED] wrote:
 
  I'm fairly new to this, and trying to understand the ORM relationship
  between a class and a table row. In most of the examples in the
  documentation, there is a one-to-one relationship; a class instance
  corresponds to a row of a table.
 
  In my application, my data falls into a 3-tier structure, represented
  by tables A, B and C. Each A has zero or more Bs, and each B and zero
  or more Cs. So, A-B is one-to-many, and B-C is one-to-many.
 
  From an application perspective, the only type of entity is a A, the
  only reason I have Bs and Cs is that SQL tables cannot have repeating
  columns (my previous database experience is with a non-SQL database
  that allows repeating data items!). I think of the Bs and Cs as just
  part of the particular A to which they belong.

 *If* I understood your point correctly (sorry if it's not the case), I
 think you are looking for one-to-many relationships to the object
 itself. This can very well be done. Just remember a one-to-many
 relationship from A to B is expressed in your table as a foreignkey
 from B to A !

 http://www.sqlalchemy.org/docs/datamapping.html#datamapping_relations_onetomany


 
  Now, in Python I can represent all the data for a particular A (ie A+B
  +C) together in one item, say a nested dictionary.

 A nested dictionary will probably be quite hard to do with SQLAlchemy alone.

  My question is, can the SQLAlchemy ORM do this for me - i.e. have a
  single class A which maps to my 3 tables A,B,C and knows how they
  are joined? If so, what should my class and table declarations look
  like (and for bounus points, can I specify the declaration using
  Elixir).

 In elixir, what you asked above (again assuming I understood what you
 wanted) would translate to:

 class A(Entity):
 has_field('name', String) # or whatever fields has the table
 ...
 belongs_to('parent', of_kind='A')
 has_many('children', of_kind='A')

 --
 Gaëtan de Menten
 http://openhex.org



-- 
Gaëtan de Menten
http://openhex.org

--~--~-~--~~~---~--~~
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] Determining class of ORM attribute at run-time

2007-05-07 Thread Cory Johns

I'm creating a general routine that is intended to take an arbitrary dict of
attribute / value pairs and an ORM object instance, and use the dict to
update the properties of the ORM instance, without knowing a priori whether
the attributes might be relations to other tables.  The problem I ran in to
is when a property that is a relation needs to be created anew, because then
I don't know what class to create an instance of.  From looking at the
source, I found what I was looking for under the argument attribute of the
PropertyLoader class, so I am currently doing along the lines of:

  attr_class = object_mapper(ormvar).properties[attr].argument
  new_instance = attr_class()
  setattr(ormvar, attr, new_instance)

However, this feels like it might be a bit fragile, as the argument
attribute isn't explicitly document that I could find.  Is there an API /
documented way of determining the class that represents a particular
attribute, as determined by mapper() or relation()?

Hope this makes sense.  Thanks.

- Cory Johns




CONFIDENTIAL NOTICE: This email including any attachments, contains 
confidential information belonging to the sender. It may also be 
privileged or otherwise protected by work product immunity or other 
legal rules. This information is intended only for the use of the 
individual or entity named above.  If you are not the intended 
recipient, you are hereby notified that any disclosure, copying, 
distribution or the taking of any action in reliance on the contents 
of this emailed information is strictly prohibited.  If you have 
received this email in error, please immediately notify us by 
reply email of the error and then delete this email immediately.

--~--~-~--~~~---~--~~
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] SQLError: ... invalid identifier

2007-05-07 Thread shday

I am getting a new error when using r2607. When I switch back to 3.6
there is no error.

Here is the stack trace:

Page handler: bound method StudyRequestController.default of
srt.controllers.StudyRequestController instance at 0x015D6620
Traceback (most recent call last):
  File C:\Python24\lib\site-packages\cherrypy-2.2.1-py2.4.egg\cherrypy
\_cphttptools.py, line 105, in _run
self.main()
  File C:\Python24\lib\site-packages\cherrypy-2.2.1-py2.4.egg\cherrypy
\_cphttptools.py, line 254, in main
body = page_handler(*virtual_path, **self.params)
  File string, line 3, in default
  File C:\Documents and Settings\Stephen\Desktop\tg_checkout
\turbogears\controllers.py, line 334, in expose
  File string, line 5, in run_with_transaction
  File c:\documents and settings\daystev\desktop\tg_checkout
\turbogears\database.py, line 354, in sa_rwt
retval = dispatch_exception(e,args,kw)
  File c:\documents and settings\daystev\desktop\tg_checkout
\turbogears\database.py, line 343, in sa_rwt
retval = func(*args, **kw)
  File string, line 5, in _expose
  File C:\Documents and Settings\Stephen\Desktop\tg_checkout
\turbogears\controllers.py, line 351, in lambda
  File C:\Documents and Settings\Stephen\Desktop\tg_checkout
\turbogears\controllers.py, line 378, in _execute_func
  File C:\Documents and Settings\Stephen\Desktop\tg_checkout
\turbogears\errorhandling.py, line 73, in try_call
  File C:\Documents and Settings\Daystev\Desktop\srt_trunk\srt-project
\srt\controllers.py, line 232, in default
return action(item, **params)
  File string, line 3, in edit
  File C:\Documents and Settings\Stephen\Desktop\tg_checkout
\turbogears\controllers.py, line 330, in expose
  File string, line 5, in _expose
  File C:\Documents and Settings\Stephen\Desktop\tg_checkout
\turbogears\controllers.py, line 351, in lambda
  File C:\Documents and Settings\Stephen\Desktop\tg_checkout
\turbogears\controllers.py, line 378, in _execute_func
  File C:\Documents and Settings\Stephen\Desktop\tg_checkout
\turbogears\errorhandling.py, line 73, in try_call
  File C:\Documents and Settings\Daystev\Desktop\srt_trunk\srt-project
\srt\controllers.py, line 251, in edit
request = dbmodel.request(request_id)
  File C:\Documents and Settings\Daystev\Desktop\srt_trunk\srt-project
\srt\model.py, line 328, in request
model_table.c.model_id == study_request_table.c.model_id))
  File c:\documents and settings\daystev\desktop\sqlalchemy_co\lib
\sqlalchemy\orm\query.py, line 270, in selectfirst
ret = self.select_whereclause(whereclause=arg, **kwargs)
  File c:\documents and settings\daystev\desktop\sqlalchemy_co\lib
\sqlalchemy\orm\query.py, line 326, in select_whereclause
return self._select_statement(statement, params=params)
  File c:\documents and settings\daystev\desktop\sqlalchemy_co\lib
\sqlalchemy\orm\query.py, line 939, in _select_statement
return self.execute(statement, params=params, **kwargs)
  File c:\documents and settings\daystev\desktop\sqlalchemy_co\lib
\sqlalchemy\orm\query.py, line 843, in execute
result = self.session.execute(self.mapper, clauseelement,
params=params)
  File c:\documents and settings\daystev\desktop\sqlalchemy_co\lib
\sqlalchemy\orm\session.py, line 183, in execute
return self.connection(mapper,
close_with_result=True).execute(clause, params, **kwargs)
  File c:\documents and settings\daystev\desktop\sqlalchemy_co\lib
\sqlalchemy\engine\base.py, line 496, in execute
return Connection.executors[c](self, object, *multiparams,
**params)
  File c:\documents and settings\daystev\desktop\sqlalchemy_co\lib
\sqlalchemy\engine\base.py, line 536, in execute_clauseelement
return self.execute_compiled(elem.compile(dialect=self.dialect,
parameters=param), *multiparams, **params)
  File c:\documents and settings\daystev\desktop\sqlalchemy_co\lib
\sqlalchemy\engine\base.py, line 547, in execute_compiled
self._execute_raw(context)
  File c:\documents and settings\daystev\desktop\sqlalchemy_co\lib
\sqlalchemy\engine\base.py, line 560, in _execute_raw
self._execute(context)
  File c:\documents and settings\daystev\desktop\sqlalchemy_co\lib
\sqlalchemy\engine\base.py, line 578, in _execute
raise exceptions.SQLError(context.statement, context.parameters,
e)
SQLError: (DatabaseError) ORA-00904:
TBL_ROW_COUNT.STUDY_REQUEST_STUDY_REQUEST_ID: invalid identifier
 'SELECT study_request.model_id AS study_request_model_id,
study_request.action_plan_wiki_id AS study_request_action_pla_2,
anon_dd00.task AS anon_dd00_task, anon_dd00.study_request_id AS
anon_dd00_study_request_id, anon_dd00.fte_days AS anon_dd00_fte_days,
study_request.animals_requested AS study_request_animals_re_3,
study_request.note AS study_request_note, study_request.media_type AS
study_request_media_type, study_request.study_date AS
study_request_study_date, study_request.study_end_date AS
study_request_study_end_date, study_request.acc_protocol_id AS
study_request_acc_protocol_id, study_request.justification AS

[sqlalchemy] Re: SQLError: ... invalid identifier

2007-05-07 Thread Michael Bayer

yeah also whats your mapper on that ?  is there a string-based  
order_by in there somewhere (or in the query.selectfirst() call) ?  i  
dont understand why that name wouldnt be truncated.

On May 7, 2007, at 3:09 PM, shday wrote:


 The table is reflected here:

 study_request_table = Table('study_request',metadata,

 Column('study_request_id',Numeric(precision=6,length=0),

 Sequence('study_request_seq'),primary_key=True,nullable=False),
 autoload=True)

 Here in what metadata.table['study_request'] gives:

 Table('study_request',DynamicMetaData(),Column 
 ('acc_protocol_id',OracleString(le
 ngth=8),ForeignKey 
 ('model_acc_protocol.acc_protocol_id'),nullable=False),Column(
 'mcode',OracleString(length=8)),Column 
 ('date_submitted',OracleDateTime(timezone=
 False)),Column('action_plan_wiki_id',OracleNumeric 
 (precision=10,length=0)),Colum
 n('fte_weeks',OracleNumeric(precision=12,length=4)),Column 
 ('fte_weekends',Oracle
 Numeric(precision=12,length=4)),Column 
 ('year_submitted',OracleNumeric(precision=
 4,length=0)),Column('study_request_id',Numeric 
 (precision=6,length=0),primary_key
 =True,nullable=False,default=Sequence 
 ('study_request_seq',start=None,increment=N
 one,optional=False)),Column('model_id',OracleNumeric 
 (precision=6,length=0),Forei
 gnKey('model_acc_protocol.model_id'),nullable=False),Column 
 ('requester_isid',Ora
 cleString(length=8),nullable=False),Column 
 ('justification',OracleString(length=4
 000)),Column('study_date',OracleDateTime 
 (timezone=False),nullable=False),Column(
 'animals_requested',OracleNumeric(precision=4,length=0)),Column 
 ('animals_used',O
 racleNumeric(precision=4,length=0)),Column('cancelled',OracleNumeric 
 (precision=1
 ,length=0),nullable=False,default=PassiveDefault 
 (sqlalchemy.sql._TextClause
 obj
 ect at
 0x016FB630)),Column('model_request_counter',OracleNumeric 
 (precision=6,le
 ngth=0),nullable=False),Column('study_end_date',OracleDateTime 
 (timezone=False),n
 ullable=False),Column('note',OracleString(length=4000)),Column 
 ('action_plan',Ora
 cleBinary(length=None)),Column('media_type',OracleString 
 (length=64)),Column('act
 ion_plan_md5',OracleString(length=32)),schema=None)

 On May 7, 2:46 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 well its generally that the identifier name is too long.  i dont
 exactly understand how its coming out without its proper truncation
 being set, and it might be related to how the oracle module redefines
 ORDER BY...so for now youd have to stick with 0.3.6 or shorten the
 column name on your table.  if you want to send me the Table for
 that i can try to create a test out of it.

 On May 7, 2007, at 2:37 PM, shday wrote:





 I am getting a new error when using r2607. When I switch back to 3.6
 there is no error.

 Here is the stack trace:

 Page handler: bound method StudyRequestController.default of
 srt.controllers.StudyRequestController instance at 0x015D6620
 Traceback (most recent call last):
   File C:\Python24\lib\site-packages\cherrypy-2.2.1-py2.4.egg
 \cherrypy
 \_cphttptools.py, line 105, in _run
 self.main()
   File C:\Python24\lib\site-packages\cherrypy-2.2.1-py2.4.egg
 \cherrypy
 \_cphttptools.py, line 254, in main
 body = page_handler(*virtual_path, **self.params)
   File string, line 3, in default
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 334, in expose
   File string, line 5, in run_with_transaction
   File c:\documents and settings\daystev\desktop\tg_checkout
 \turbogears\database.py, line 354, in sa_rwt
 retval = dispatch_exception(e,args,kw)
   File c:\documents and settings\daystev\desktop\tg_checkout
 \turbogears\database.py, line 343, in sa_rwt
 retval = func(*args, **kw)
   File string, line 5, in _expose
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 351, in lambda
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 378, in _execute_func
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\errorhandling.py, line 73, in try_call
   File C:\Documents and Settings\Daystev\Desktop\srt_trunk\srt-
 project
 \srt\controllers.py, line 232, in default
 return action(item, **params)
   File string, line 3, in edit
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 330, in expose
   File string, line 5, in _expose
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 351, in lambda
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 378, in _execute_func
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\errorhandling.py, line 73, in try_call
   File C:\Documents and Settings\Daystev\Desktop\srt_trunk\srt-
 project
 \srt\controllers.py, line 251, in edit
 request = dbmodel.request(request_id)
   File C:\Documents and 

[sqlalchemy] Re: SQLError: ... invalid identifier

2007-05-07 Thread Michael Bayer

also is there a count() stuck in there somewhere ?  the  
tbl_row_count identifier only comes into play when theres count().

On May 7, 2007, at 3:09 PM, shday wrote:


 The table is reflected here:

 study_request_table = Table('study_request',metadata,

 Column('study_request_id',Numeric(precision=6,length=0),

 Sequence('study_request_seq'),primary_key=True,nullable=False),
 autoload=True)

 Here in what metadata.table['study_request'] gives:

 Table('study_request',DynamicMetaData(),Column 
 ('acc_protocol_id',OracleString(le
 ngth=8),ForeignKey 
 ('model_acc_protocol.acc_protocol_id'),nullable=False),Column(
 'mcode',OracleString(length=8)),Column 
 ('date_submitted',OracleDateTime(timezone=
 False)),Column('action_plan_wiki_id',OracleNumeric 
 (precision=10,length=0)),Colum
 n('fte_weeks',OracleNumeric(precision=12,length=4)),Column 
 ('fte_weekends',Oracle
 Numeric(precision=12,length=4)),Column 
 ('year_submitted',OracleNumeric(precision=
 4,length=0)),Column('study_request_id',Numeric 
 (precision=6,length=0),primary_key
 =True,nullable=False,default=Sequence 
 ('study_request_seq',start=None,increment=N
 one,optional=False)),Column('model_id',OracleNumeric 
 (precision=6,length=0),Forei
 gnKey('model_acc_protocol.model_id'),nullable=False),Column 
 ('requester_isid',Ora
 cleString(length=8),nullable=False),Column 
 ('justification',OracleString(length=4
 000)),Column('study_date',OracleDateTime 
 (timezone=False),nullable=False),Column(
 'animals_requested',OracleNumeric(precision=4,length=0)),Column 
 ('animals_used',O
 racleNumeric(precision=4,length=0)),Column('cancelled',OracleNumeric 
 (precision=1
 ,length=0),nullable=False,default=PassiveDefault 
 (sqlalchemy.sql._TextClause
 obj
 ect at
 0x016FB630)),Column('model_request_counter',OracleNumeric 
 (precision=6,le
 ngth=0),nullable=False),Column('study_end_date',OracleDateTime 
 (timezone=False),n
 ullable=False),Column('note',OracleString(length=4000)),Column 
 ('action_plan',Ora
 cleBinary(length=None)),Column('media_type',OracleString 
 (length=64)),Column('act
 ion_plan_md5',OracleString(length=32)),schema=None)

 On May 7, 2:46 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 well its generally that the identifier name is too long.  i dont
 exactly understand how its coming out without its proper truncation
 being set, and it might be related to how the oracle module redefines
 ORDER BY...so for now youd have to stick with 0.3.6 or shorten the
 column name on your table.  if you want to send me the Table for
 that i can try to create a test out of it.

 On May 7, 2007, at 2:37 PM, shday wrote:





 I am getting a new error when using r2607. When I switch back to 3.6
 there is no error.

 Here is the stack trace:

 Page handler: bound method StudyRequestController.default of
 srt.controllers.StudyRequestController instance at 0x015D6620
 Traceback (most recent call last):
   File C:\Python24\lib\site-packages\cherrypy-2.2.1-py2.4.egg
 \cherrypy
 \_cphttptools.py, line 105, in _run
 self.main()
   File C:\Python24\lib\site-packages\cherrypy-2.2.1-py2.4.egg
 \cherrypy
 \_cphttptools.py, line 254, in main
 body = page_handler(*virtual_path, **self.params)
   File string, line 3, in default
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 334, in expose
   File string, line 5, in run_with_transaction
   File c:\documents and settings\daystev\desktop\tg_checkout
 \turbogears\database.py, line 354, in sa_rwt
 retval = dispatch_exception(e,args,kw)
   File c:\documents and settings\daystev\desktop\tg_checkout
 \turbogears\database.py, line 343, in sa_rwt
 retval = func(*args, **kw)
   File string, line 5, in _expose
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 351, in lambda
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 378, in _execute_func
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\errorhandling.py, line 73, in try_call
   File C:\Documents and Settings\Daystev\Desktop\srt_trunk\srt-
 project
 \srt\controllers.py, line 232, in default
 return action(item, **params)
   File string, line 3, in edit
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 330, in expose
   File string, line 5, in _expose
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 351, in lambda
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 378, in _execute_func
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\errorhandling.py, line 73, in try_call
   File C:\Documents and Settings\Daystev\Desktop\srt_trunk\srt-
 project
 \srt\controllers.py, line 251, in edit
 request = dbmodel.request(request_id)
   File C:\Documents and Settings\Daystev\Desktop\srt_trunk\srt-
 project
 \srt\model.py, 

[sqlalchemy] Re: SQLError: ... invalid identifier

2007-05-07 Thread shday

The mapper:

mapper(StudyRequest,study_request_table,properties={'model':relation(Model,
 
primaryjoin=model_table.c.model_id==study_request_table.c.model_id,
 
foreign_keys=[study_request_table.c.model_id],
lazy=False), #backref doesn't work
in 3.6
 
'technicians':relation(TechnicianStudyRequest,backref='study_request',lazy=False),
 
'action_plans':relation(ActionPlan,backref='study_request',lazy=True),
 
'comp_med_resources':relation(CompMedResource,backref='study_request',lazy=False)})

The selectfirst:

request = session.query(StudyRequest).selectfirst(
and_(model_table.c.model_acronym == acronym,
study_request_table.c.model_request_counter == counter,
model_table.c.model_id == study_request_table.c.model_id))

Could the problem have something to do with the column being Numeric
instead of OracleNumeric? Seems to be that way because reflection was
overridden.




On May 7, 3:14 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 yeah also whats your mapper on that ?  is there a string-based  
 order_by in there somewhere (or in the query.selectfirst() call) ?  i  
 dont understand why that name wouldnt be truncated.

 On May 7, 2007, at 3:09 PM, shday wrote:





  The table is reflected here:

  study_request_table = Table('study_request',metadata,

  Column('study_request_id',Numeric(precision=6,length=0),

  Sequence('study_request_seq'),primary_key=True,nullable=False),
  autoload=True)

  Here in what metadata.table['study_request'] gives:

  Table('study_request',DynamicMetaData(),Column
  ('acc_protocol_id',OracleString(le
  ngth=8),ForeignKey
  ('model_acc_protocol.acc_protocol_id'),nullable=False),Column(
  'mcode',OracleString(length=8)),Column
  ('date_submitted',OracleDateTime(timezone=
  False)),Column('action_plan_wiki_id',OracleNumeric
  (precision=10,length=0)),Colum
  n('fte_weeks',OracleNumeric(precision=12,length=4)),Column
  ('fte_weekends',Oracle
  Numeric(precision=12,length=4)),Column
  ('year_submitted',OracleNumeric(precision=
  4,length=0)),Column('study_request_id',Numeric
  (precision=6,length=0),primary_key
  =True,nullable=False,default=Sequence
  ('study_request_seq',start=None,increment=N
  one,optional=False)),Column('model_id',OracleNumeric
  (precision=6,length=0),Forei
  gnKey('model_acc_protocol.model_id'),nullable=False),Column
  ('requester_isid',Ora
  cleString(length=8),nullable=False),Column
  ('justification',OracleString(length=4
  000)),Column('study_date',OracleDateTime
  (timezone=False),nullable=False),Column(
  'animals_requested',OracleNumeric(precision=4,length=0)),Column
  ('animals_used',O
  racleNumeric(precision=4,length=0)),Column('cancelled',OracleNumeric
  (precision=1
  ,length=0),nullable=False,default=PassiveDefault
  (sqlalchemy.sql._TextClause
  obj
  ect at
  0x016FB630)),Column('model_request_counter',OracleNumeric
  (precision=6,le
  ngth=0),nullable=False),Column('study_end_date',OracleDateTime
  (timezone=False),n
  ullable=False),Column('note',OracleString(length=4000)),Column
  ('action_plan',Ora
  cleBinary(length=None)),Column('media_type',OracleString
  (length=64)),Column('act
  ion_plan_md5',OracleString(length=32)),schema=None)

  On May 7, 2:46 pm, Michael Bayer [EMAIL PROTECTED] wrote:
  well its generally that the identifier name is too long.  i dont
  exactly understand how its coming out without its proper truncation
  being set, and it might be related to how the oracle module redefines
  ORDER BY...so for now youd have to stick with 0.3.6 or shorten the
  column name on your table.  if you want to send me the Table for
  that i can try to create a test out of it.

  On May 7, 2007, at 2:37 PM, shday wrote:

  I am getting a new error when using r2607. When I switch back to 3.6
  there is no error.

  Here is the stack trace:

  Page handler: bound method StudyRequestController.default of
  srt.controllers.StudyRequestController instance at 0x015D6620
  Traceback (most recent call last):
File C:\Python24\lib\site-packages\cherrypy-2.2.1-py2.4.egg
  \cherrypy
  \_cphttptools.py, line 105, in _run
  self.main()
File C:\Python24\lib\site-packages\cherrypy-2.2.1-py2.4.egg
  \cherrypy
  \_cphttptools.py, line 254, in main
  body = page_handler(*virtual_path, **self.params)
File string, line 3, in default
File C:\Documents and Settings\Stephen\Desktop\tg_checkout
  \turbogears\controllers.py, line 334, in expose
File string, line 5, in run_with_transaction
File c:\documents and settings\daystev\desktop\tg_checkout
  \turbogears\database.py, line 354, in sa_rwt
  retval = dispatch_exception(e,args,kw)
File c:\documents and settings\daystev\desktop\tg_checkout
  \turbogears\database.py, line 343, in sa_rwt
  retval = func(*args, **kw)
File string, line 5, in _expose
File C:\Documents and Settings\Stephen\Desktop\tg_checkout
  \turbogears\controllers.py, line 351, in lambda
File 

[sqlalchemy] Re: SQLError: ... invalid identifier

2007-05-07 Thread shday

No count() anywhere.

On May 7, 3:17 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 also is there a count() stuck in there somewhere ?  the  
 tbl_row_count identifier only comes into play when theres count().

 On May 7, 2007, at 3:09 PM, shday wrote:





  The table is reflected here:

  study_request_table = Table('study_request',metadata,

  Column('study_request_id',Numeric(precision=6,length=0),

  Sequence('study_request_seq'),primary_key=True,nullable=False),
  autoload=True)

  Here in what metadata.table['study_request'] gives:

  Table('study_request',DynamicMetaData(),Column
  ('acc_protocol_id',OracleString(le
  ngth=8),ForeignKey
  ('model_acc_protocol.acc_protocol_id'),nullable=False),Column(
  'mcode',OracleString(length=8)),Column
  ('date_submitted',OracleDateTime(timezone=
  False)),Column('action_plan_wiki_id',OracleNumeric
  (precision=10,length=0)),Colum
  n('fte_weeks',OracleNumeric(precision=12,length=4)),Column
  ('fte_weekends',Oracle
  Numeric(precision=12,length=4)),Column
  ('year_submitted',OracleNumeric(precision=
  4,length=0)),Column('study_request_id',Numeric
  (precision=6,length=0),primary_key
  =True,nullable=False,default=Sequence
  ('study_request_seq',start=None,increment=N
  one,optional=False)),Column('model_id',OracleNumeric
  (precision=6,length=0),Forei
  gnKey('model_acc_protocol.model_id'),nullable=False),Column
  ('requester_isid',Ora
  cleString(length=8),nullable=False),Column
  ('justification',OracleString(length=4
  000)),Column('study_date',OracleDateTime
  (timezone=False),nullable=False),Column(
  'animals_requested',OracleNumeric(precision=4,length=0)),Column
  ('animals_used',O
  racleNumeric(precision=4,length=0)),Column('cancelled',OracleNumeric
  (precision=1
  ,length=0),nullable=False,default=PassiveDefault
  (sqlalchemy.sql._TextClause
  obj
  ect at
  0x016FB630)),Column('model_request_counter',OracleNumeric
  (precision=6,le
  ngth=0),nullable=False),Column('study_end_date',OracleDateTime
  (timezone=False),n
  ullable=False),Column('note',OracleString(length=4000)),Column
  ('action_plan',Ora
  cleBinary(length=None)),Column('media_type',OracleString
  (length=64)),Column('act
  ion_plan_md5',OracleString(length=32)),schema=None)

  On May 7, 2:46 pm, Michael Bayer [EMAIL PROTECTED] wrote:
  well its generally that the identifier name is too long.  i dont
  exactly understand how its coming out without its proper truncation
  being set, and it might be related to how the oracle module redefines
  ORDER BY...so for now youd have to stick with 0.3.6 or shorten the
  column name on your table.  if you want to send me the Table for
  that i can try to create a test out of it.

  On May 7, 2007, at 2:37 PM, shday wrote:

  I am getting a new error when using r2607. When I switch back to 3.6
  there is no error.

  Here is the stack trace:

  Page handler: bound method StudyRequestController.default of
  srt.controllers.StudyRequestController instance at 0x015D6620
  Traceback (most recent call last):
File C:\Python24\lib\site-packages\cherrypy-2.2.1-py2.4.egg
  \cherrypy
  \_cphttptools.py, line 105, in _run
  self.main()
File C:\Python24\lib\site-packages\cherrypy-2.2.1-py2.4.egg
  \cherrypy
  \_cphttptools.py, line 254, in main
  body = page_handler(*virtual_path, **self.params)
File string, line 3, in default
File C:\Documents and Settings\Stephen\Desktop\tg_checkout
  \turbogears\controllers.py, line 334, in expose
File string, line 5, in run_with_transaction
File c:\documents and settings\daystev\desktop\tg_checkout
  \turbogears\database.py, line 354, in sa_rwt
  retval = dispatch_exception(e,args,kw)
File c:\documents and settings\daystev\desktop\tg_checkout
  \turbogears\database.py, line 343, in sa_rwt
  retval = func(*args, **kw)
File string, line 5, in _expose
File C:\Documents and Settings\Stephen\Desktop\tg_checkout
  \turbogears\controllers.py, line 351, in lambda
File C:\Documents and Settings\Stephen\Desktop\tg_checkout
  \turbogears\controllers.py, line 378, in _execute_func
File C:\Documents and Settings\Stephen\Desktop\tg_checkout
  \turbogears\errorhandling.py, line 73, in try_call
File C:\Documents and Settings\Daystev\Desktop\srt_trunk\srt-
  project
  \srt\controllers.py, line 232, in default
  return action(item, **params)
File string, line 3, in edit
File C:\Documents and Settings\Stephen\Desktop\tg_checkout
  \turbogears\controllers.py, line 330, in expose
File string, line 5, in _expose
File C:\Documents and Settings\Stephen\Desktop\tg_checkout
  \turbogears\controllers.py, line 351, in lambda
File C:\Documents and Settings\Stephen\Desktop\tg_checkout
  \turbogears\controllers.py, line 378, in _execute_func
File C:\Documents and Settings\Stephen\Desktop\tg_checkout
  \turbogears\errorhandling.py, line 73, in try_call
File C:\Documents and Settings\Daystev\Desktop\srt_trunk\srt-
  project
  

[sqlalchemy] Re: SQLError: ... invalid identifier

2007-05-07 Thread Michael Bayer

k i got it, rev 2609.

On May 7, 2007, at 3:44 PM, shday wrote:


 The mapper:

 mapper(StudyRequest,study_request_table,properties={'model':relation 
 (Model,

 primaryjoin=model_table.c.model_id==study_request_table.c.model_id,

 foreign_keys=[study_request_table.c.model_id],
 lazy=False), #backref doesn't work
 in 3.6

 'technicians':relation 
 (TechnicianStudyRequest,backref='study_request',lazy=False),

 'action_plans':relation(ActionPlan,backref='study_request',lazy=True),

 'comp_med_resources':relation 
 (CompMedResource,backref='study_request',lazy=False)})

 The selectfirst:

 request = session.query(StudyRequest).selectfirst(
 and_(model_table.c.model_acronym == acronym,
 study_request_table.c.model_request_counter == counter,
 model_table.c.model_id == study_request_table.c.model_id))

 Could the problem have something to do with the column being Numeric
 instead of OracleNumeric? Seems to be that way because reflection was
 overridden.




 On May 7, 3:14 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 yeah also whats your mapper on that ?  is there a string-based
 order_by in there somewhere (or in the query.selectfirst() call) ?  i
 dont understand why that name wouldnt be truncated.

 On May 7, 2007, at 3:09 PM, shday wrote:





 The table is reflected here:

 study_request_table = Table('study_request',metadata,

 Column('study_request_id',Numeric(precision=6,length=0),

 Sequence('study_request_seq'),primary_key=True,nullable=False),
 autoload=True)

 Here in what metadata.table['study_request'] gives:

 Table('study_request',DynamicMetaData(),Column
 ('acc_protocol_id',OracleString(le
 ngth=8),ForeignKey
 ('model_acc_protocol.acc_protocol_id'),nullable=False),Column(
 'mcode',OracleString(length=8)),Column
 ('date_submitted',OracleDateTime(timezone=
 False)),Column('action_plan_wiki_id',OracleNumeric
 (precision=10,length=0)),Colum
 n('fte_weeks',OracleNumeric(precision=12,length=4)),Column
 ('fte_weekends',Oracle
 Numeric(precision=12,length=4)),Column
 ('year_submitted',OracleNumeric(precision=
 4,length=0)),Column('study_request_id',Numeric
 (precision=6,length=0),primary_key
 =True,nullable=False,default=Sequence
 ('study_request_seq',start=None,increment=N
 one,optional=False)),Column('model_id',OracleNumeric
 (precision=6,length=0),Forei
 gnKey('model_acc_protocol.model_id'),nullable=False),Column
 ('requester_isid',Ora
 cleString(length=8),nullable=False),Column
 ('justification',OracleString(length=4
 000)),Column('study_date',OracleDateTime
 (timezone=False),nullable=False),Column(
 'animals_requested',OracleNumeric(precision=4,length=0)),Column
 ('animals_used',O
 racleNumeric(precision=4,length=0)),Column('cancelled',OracleNumeric
 (precision=1
 ,length=0),nullable=False,default=PassiveDefault
 (sqlalchemy.sql._TextClause
 obj
 ect at
 0x016FB630)),Column('model_request_counter',OracleNumeric
 (precision=6,le
 ngth=0),nullable=False),Column('study_end_date',OracleDateTime
 (timezone=False),n
 ullable=False),Column('note',OracleString(length=4000)),Column
 ('action_plan',Ora
 cleBinary(length=None)),Column('media_type',OracleString
 (length=64)),Column('act
 ion_plan_md5',OracleString(length=32)),schema=None)

 On May 7, 2:46 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 well its generally that the identifier name is too long.  i dont
 exactly understand how its coming out without its proper truncation
 being set, and it might be related to how the oracle module  
 redefines
 ORDER BY...so for now youd have to stick with 0.3.6 or shorten  
 the
 column name on your table.  if you want to send me the Table for
 that i can try to create a test out of it.

 On May 7, 2007, at 2:37 PM, shday wrote:

 I am getting a new error when using r2607. When I switch back  
 to 3.6
 there is no error.

 Here is the stack trace:

 Page handler: bound method StudyRequestController.default of
 srt.controllers.StudyRequestController instance at 0x015D6620
 Traceback (most recent call last):
   File C:\Python24\lib\site-packages\cherrypy-2.2.1-py2.4.egg
 \cherrypy
 \_cphttptools.py, line 105, in _run
 self.main()
   File C:\Python24\lib\site-packages\cherrypy-2.2.1-py2.4.egg
 \cherrypy
 \_cphttptools.py, line 254, in main
 body = page_handler(*virtual_path, **self.params)
   File string, line 3, in default
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 334, in expose
   File string, line 5, in run_with_transaction
   File c:\documents and settings\daystev\desktop\tg_checkout
 \turbogears\database.py, line 354, in sa_rwt
 retval = dispatch_exception(e,args,kw)
   File c:\documents and settings\daystev\desktop\tg_checkout
 \turbogears\database.py, line 343, in sa_rwt
 retval = func(*args, **kw)
   File string, line 5, in _expose
   File C:\Documents and Settings\Stephen\Desktop\tg_checkout
 \turbogears\controllers.py, line 351, in lambda