[sqlalchemy] PickleType to use mediumblob

2011-07-18 Thread rajasekhar911
Hi

I want PickleType to use mediumblob instead of blob.
i am trying the following

from sqlalchemy.databases.mysql import MSMediumBlob
class MediumPickle(PickleType):
impl = mysql.MSMediumBlob


class Task(DeclarativeBase):
__tablename__ = 'tasks'

context = Column(MediumPickle)

is this ok or are there any better way to do this?

thnx in advnace

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: EOFError while querying

2011-07-06 Thread rajasekhar911
Hi

Is there a way that, i can validate the values in BLOB column (the
binary data) maps to a valid pickle string.

if I dump the data from the row to a file, will it be of any use?
select results into dumpfile '/tmp/blob_data.txt' from task_results
where task_id=1;

is there any utility that i can make use of?

Thanks in advance

On Jul 5, 6:30 pm, rajasekhar911 rajasekhar...@gmail.com wrote:
 Hi Michael

 thanks for the reply.
 there is a PickleType in the query (the one that i have mentioned as
 BLOB data type).
 I have given a test program to the customer and waiting for the
 response.

 thanks again

 On Jul 4, 8:01 pm, Michael Bayer mike...@zzzcomputing.com wrote:

  loads() implies you're using PickleType even though not indicated here 
  (just a query by itself tells us very little btw) and theEOFErrorimplies 
  the binary data being loaded is not a valid pickle string.

  On Jul 4, 2011, at 3:09 AM, rajasekhar911 wrote:

   Hi ,

   I am gettingEOFErrorwhile querying a table . The select contains
   String fields, integer fields , a BLOB and a TEXT filed.
   The error happens consistently. This is happening in a customer envt.
   Anybody has any idea on what could be the issue?

   Thanks in advance

   stack trace is given below
   
   Traceback (most recent call last):
    File ./xx/src/xx/web/xx/xx/controllers/
   ControllerImpl.py, line 286, in get_tasks
    File ./xx/src/xx/web/xx/xx/viewModel/Userinfo.py,
   line 1602, in get_tasks
    File /home/xx/xx/tg2env/lib/python2.6/site-packages/
   SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/query.py, line 1267, in all
      return list(self)
    File /home/xx/xx/tg2env/lib/python2.6/site-packages/
   SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/query.py, line 1425, in
   instances
      for row in fetch]
    File /home/xx/xx/tg2env/lib/python2.6/site-packages/
   SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/query.py, line 1424, in
   genexpr
      rows = [rowtuple(proc(context, row) for proc in process)
    File /home/xx/xx/tg2env/lib/python2.6/site-packages/
   SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/query.py, line 2156, in
   proc
      return row[column]
    File /home/xx/xx/tg2env/lib/python2.6/site-packages/
   SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/engine/base.py, line 1348, in
   __getitem__
      return self.__parent._get_col(self.__row, key)
    File /home/xx/xx/tg2env/lib/python2.6/site-packages/
   SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/engine/base.py, line 1620, in
   _get_col
      return processor(row[index])
    File /home/xx/xx/tg2env/lib/python2.6/site-packages/
   SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/types.py, line 284, in process
      return self.process_result_value(impl_processor(value), dialect)
    File /home/xx/xx/tg2env/lib/python2.6/site-packages/
   SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/types.py, line 778, in
   process_result_value
      return loads(str(value))
  EOFError

   query is as follows
   
   tasks=DBSession.query(Task.task_id, Task.name, Task.user_name,
   Task.entity_name, Task.cancellable, \
                                  TaskResult.timestamp,
   TaskResult.endtime, TaskResult.status, TaskResult.results, \
                                  Task.entity_type, Task.short_desc).\
               join(TaskResult).\
               filter(and_(Task.repeating == True,TaskResult.visible ==
   True)).\
               filter(Task.submitted_on = ago).\
               order_by(TaskResult.timestamp.desc()).limit(limit).all()

   Thanks

   --
   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 
   sqlalchemy+unsubscr...@googlegroups.com.
   For more options, visit this group 
   athttp://groups.google.com/group/sqlalchemy?hl=en.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: EOFError while querying

2011-07-05 Thread rajasekhar911
Hi Michael

thanks for the reply.
there is a PickleType in the query (the one that i have mentioned as
BLOB data type).
I have given a test program to the customer and waiting for the
response.

thanks again

On Jul 4, 8:01 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 loads() implies you're using PickleType even though not indicated here (just 
 a query by itself tells us very little btw) and the EOFError implies the 
 binary data being loaded is not a valid pickle string.

 On Jul 4, 2011, at 3:09 AM, rajasekhar911 wrote:

  Hi ,

  I am getting EOFError while querying a table . The select contains
  String fields, integer fields , a BLOB and a TEXT filed.
  The error happens consistently. This is happening in a customer envt.
  Anybody has any idea on what could be the issue?

  Thanks in advance

  stack trace is given below
  
  Traceback (most recent call last):
   File ./xx/src/xx/web/xx/xx/controllers/
  ControllerImpl.py, line 286, in get_tasks
   File ./xx/src/xx/web/xx/xx/viewModel/Userinfo.py,
  line 1602, in get_tasks
   File /home/xx/xx/tg2env/lib/python2.6/site-packages/
  SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/query.py, line 1267, in all
     return list(self)
   File /home/xx/xx/tg2env/lib/python2.6/site-packages/
  SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/query.py, line 1425, in
  instances
     for row in fetch]
   File /home/xx/xx/tg2env/lib/python2.6/site-packages/
  SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/query.py, line 1424, in
  genexpr
     rows = [rowtuple(proc(context, row) for proc in process)
   File /home/xx/xx/tg2env/lib/python2.6/site-packages/
  SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/query.py, line 2156, in
  proc
     return row[column]
   File /home/xx/xx/tg2env/lib/python2.6/site-packages/
  SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/engine/base.py, line 1348, in
  __getitem__
     return self.__parent._get_col(self.__row, key)
   File /home/xx/xx/tg2env/lib/python2.6/site-packages/
  SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/engine/base.py, line 1620, in
  _get_col
     return processor(row[index])
   File /home/xx/xx/tg2env/lib/python2.6/site-packages/
  SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/types.py, line 284, in process
     return self.process_result_value(impl_processor(value), dialect)
   File /home/xx/xx/tg2env/lib/python2.6/site-packages/
  SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/types.py, line 778, in
  process_result_value
     return loads(str(value))
  EOFError

  query is as follows
  
  tasks=DBSession.query(Task.task_id, Task.name, Task.user_name,
  Task.entity_name, Task.cancellable, \
                                 TaskResult.timestamp,
  TaskResult.endtime, TaskResult.status, TaskResult.results, \
                                 Task.entity_type, Task.short_desc).\
              join(TaskResult).\
              filter(and_(Task.repeating == True,TaskResult.visible ==
  True)).\
              filter(Task.submitted_on = ago).\
              order_by(TaskResult.timestamp.desc()).limit(limit).all()

  Thanks

  --
  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 
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/sqlalchemy?hl=en.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] EOFError while querying

2011-07-04 Thread rajasekhar911
Hi ,

I am getting EOFError while querying a table . The select contains
String fields, integer fields , a BLOB and a TEXT filed.
The error happens consistently. This is happening in a customer envt.
Anybody has any idea on what could be the issue?

Thanks in advance

stack trace is given below

Traceback (most recent call last):
  File ./xx/src/xx/web/xx/xx/controllers/
ControllerImpl.py, line 286, in get_tasks
  File ./xx/src/xx/web/xx/xx/viewModel/Userinfo.py,
line 1602, in get_tasks
  File /home/xx/xx/tg2env/lib/python2.6/site-packages/
SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/query.py, line 1267, in all
return list(self)
  File /home/xx/xx/tg2env/lib/python2.6/site-packages/
SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/query.py, line 1425, in
instances
for row in fetch]
  File /home/xx/xx/tg2env/lib/python2.6/site-packages/
SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/query.py, line 1424, in
genexpr
rows = [rowtuple(proc(context, row) for proc in process)
  File /home/xx/xx/tg2env/lib/python2.6/site-packages/
SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/query.py, line 2156, in
proc
return row[column]
  File /home/xx/xx/tg2env/lib/python2.6/site-packages/
SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/engine/base.py, line 1348, in
__getitem__
return self.__parent._get_col(self.__row, key)
  File /home/xx/xx/tg2env/lib/python2.6/site-packages/
SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/engine/base.py, line 1620, in
_get_col
return processor(row[index])
  File /home/xx/xx/tg2env/lib/python2.6/site-packages/
SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/types.py, line 284, in process
return self.process_result_value(impl_processor(value), dialect)
  File /home/xx/xx/tg2env/lib/python2.6/site-packages/
SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/types.py, line 778, in
process_result_value
return loads(str(value))
EOFError


query is as follows

tasks=DBSession.query(Task.task_id, Task.name, Task.user_name,
Task.entity_name, Task.cancellable, \
TaskResult.timestamp,
TaskResult.endtime, TaskResult.status, TaskResult.results, \
Task.entity_type, Task.short_desc).\
 join(TaskResult).\
 filter(and_(Task.repeating == True,TaskResult.visible ==
True)).\
 filter(Task.submitted_on = ago).\
 order_by(TaskResult.timestamp.desc()).limit(limit).all()


Thanks

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] how to handle deadlock

2010-05-06 Thread rajasekhar911
Hi

I am using sqlalchemy0.5.5 in my TG2 app with mysql(innodb) database
My applicaton is multithreaded.
there are multiple tasks that run at certain intervals.
in one of my tables i am getting the following deadlock error.
Deadlock found when trying to get lock; try restarting transaction

the query was failing while trying to delete in the following way.
DBSession.query(Metrics).filter(Metrics.type_id==type_id).filter(Metrics.cdate
= date1).delete()

so i changed the code to
rows =
DBSession.query(Metrics).filter(Metrics.type_id==type_id).filter(Metrics.cdate
= date1).all()
for row in rows :
DBSession.delete(row)
assuming that it will scan less no:of rows while deleting. In this way
i am no longer seeing the deadlock error.
but if anybody can clarify that this is reliable enough or suggest any
other options ,
that would be really helpful

thanks

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



[sqlalchemy] Assertion Error

2010-03-18 Thread rajasekhar911
Hi guys

I got this weird AsserstionError and KeyError. It says it is ignored.
The class Credential is a mapped as a relation to the parent class.

credential=relation(Credential, \
primaryjoin=id == Credential.n_id,\
foreign_keys=[Credential.n_id],\
uselist=False,cascade='all, delete, delete-
orphan')

Exception AssertionError: AssertionError('State
sqlalchemy.orm.state.InstanceState object at 0x9f0e12c is not
present in this identity map',) in bound method
InstanceState._cleanup of sqlalchemy.orm.state.InstanceState object
at 0x9f0e12c ignored

Exception AssertionError: AssertionError('State
sqlalchemy.orm.state.MutableAttrInstanceState object at 0x9f0eeac is
not present in this identity map',) in bound method
MutableAttrInstanceState._cleanup of
sqlalchemy.orm.state.MutableAttrInstanceState object at 0x9f0eeac
ignored

Exception AssertionError: AssertionError('State
sqlalchemy.orm.state.MutableAttrInstanceState object at 0xa913942c
is not present in this identity map',) in bound method
MutableAttrInstanceState._cleanup of
sqlalchemy.orm.state.MutableAttrInstanceState object at 0xa913942c
ignored

Exception KeyError: ((class 'model.Credential.Credential',
(u'6d73d41c-e4ad-a525-1f71-3cf6b1595f05',)),) in bound method
MutableAttrInstanceState._cleanup of
sqlalchemy.orm.state.MutableAttrInstanceState object at 0xa7f7c3ac
ignored

is this just a warning or an actual exception..
i tried googling , turned out nothing.

thnx in advance.

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



[sqlalchemy] integrity error in FK relation

2009-12-01 Thread rajasekhar911
i have following relation b/w 3 tables

class A(DeclarativeBase)
__tablename__='a'
id=Column(Unicode(50))#primarykey
name=Column(Unicode(50))
cc=relation(C, \
primaryjoin=id == C.b_id,\
foreign_keys=[C.b_id],\
uselist=False,cascade='all, delete, delete-
orphan')

class B(DeclarativeBase)
__tablename__='b'
id=Column(Unicode(50))#primarykey
name=Column(Unicode(50))


class C(DeclarativeBase)
__tablename__='c'
id=Column(Integer)#primarykey
name=Column(Unicode(50))
b_id=Column(Unicode(50),ForeignKey('b.id',\
onupdate=CASCADE,ondelete=CASCADE))

bb=B(name='bb')
aa=A(name='aa')
aa.cc=C(name='ca',b_id=bb.id)
DBSession.add(bb)
DBSession.add(aa)

throws

(IntegrityError) (1452, Cannot add or update a child row: a foreign
key constraint fails (`test/c`, CONSTRAINT `c_ibfk_1` FOREIGN KEY
(`b_id`) REFERENCES `b` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) )
u INSERT INTO c (id, b_id, name) VALUES (%s, %s, %s)

if i do a flush in b/w the add it works fine
DBSession.add(bb)
DBSession.flush()
DBSession.add(aa)

even
bb=B(name='bb')
cc=C(name='ca',b_id=bb.id)--removed the relation from B
DBSession.add(bb)
DBSession.add(cc)
throws the same error

I am working on turbogears 2.0, SQLAlchemy0.5.6
session is created with autoflush=true and autocommit=true
mysql 5.0 with innodb engine

shouldn't the flush takes place by default or the transaction should
take care of it?

--

You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.




[sqlalchemy] Re: integrity error in FK relation

2009-12-01 Thread rajasekhar911
but this happen only when i use innodb as engine.
didnt give an error on myisam on mysql or sqlite.


On Dec 2, 3:12 am, Michael Bayer mike...@zzzcomputing.com wrote:
 On Dec 1, 2009, at 2:16 PM, rajasekhar911 wrote:



  i have following relation b/w 3 tables

  class A(DeclarativeBase)
  __tablename__='a'
  id=Column(Unicode(50))#primarykey
  name=Column(Unicode(50))
  cc=relation(C, \
                     primaryjoin=id == C.b_id,\
                     foreign_keys=[C.b_id],\
                     uselist=False,cascade='all, delete, delete-
  orphan')

  class B(DeclarativeBase)
  __tablename__='b'
  id=Column(Unicode(50))#primarykey
  name=Column(Unicode(50))

  class C(DeclarativeBase)
  __tablename__='c'
  id=Column(Integer)#primarykey
  name=Column(Unicode(50))
  b_id=Column(Unicode(50),ForeignKey('b.id',\
                     onupdate=CASCADE,ondelete=CASCADE))

  bb=B(name='bb')
  aa=A(name='aa')
  aa.cc=C(name='ca',b_id=bb.id)

 you haven't established a relation() between C and B here so SQLA has no 
 awareness that B needs to be inserted before C.  Also bb.id is None until the 
 session is flushed.   If you use a relation() from C to B, that would solve 
 the issue.  Also A.cc is strange here in that you're repurposing the foreign 
 key C.b_id to point to A which is nonsensical to be on A, which has nothing 
 to do with B.

  DBSession.add(bb)
  DBSession.add(aa)

  throws

  (IntegrityError) (1452, Cannot add or update a child row: a foreign
  key constraint fails (`test/c`, CONSTRAINT `c_ibfk_1` FOREIGN KEY
  (`b_id`) REFERENCES `b` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) )
  u INSERT INTO c (id, b_id, name) VALUES (%s, %s, %s)

  if i do a flush in b/w the add it works fine
  DBSession.add(bb)
  DBSession.flush()
  DBSession.add(aa)

  even
  bb=B(name='bb')
  cc=C(name='ca',b_id=bb.id)--removed the relation from B
  DBSession.add(bb)
  DBSession.add(cc)
  throws the same error

  I am working on turbogears 2.0, SQLAlchemy0.5.6
  session is created with autoflush=true and autocommit=true
  mysql 5.0 with innodb engine

  shouldn't the flush takes place by default or the transaction should
  take care of it?

  --

  You received this message because you are subscribed to the Google Groups 
  sqlalchemy group.
  To post to this group, send email to sqlalch...@googlegroups.com.
  To unsubscribe from this group, send email to 
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/sqlalchemy?hl=en.

--

You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.




[sqlalchemy] Re: column label and order by

2009-11-17 Thread rajasekhar911

anyone??

On Nov 14, 6:48 pm, rajasekhar911 rajasekhar...@gmail.com wrote:
 Hi guys,

 how do i apply order by on a column with a label.
 My requirement is like this

 class x
   id,
   amount,
   date

 i have to group based on id and take sum of amount within a date
 range.

 i am applying a label to sum of amount
 now how do i order based on that so that i can get top 5 ..

 session.query( func.sum(x.amount).label('tot_amount'), x.id ).
 filter(x.datefromdate).filter(x.datetodate).
 .group_by(x.id)
 .order_by(?)
 .limit(5)

 thanks.
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: column label and order by

2009-11-17 Thread rajasekhar911

session.query( func.sum(x.amount).label('tot_amount'), x.id ).
filter(x.datefromdate).filter(x.datetodate).
.group_by(x.id)
.order_by('tot_amount DESC')
.limit(5)

On Nov 17, 4:55 pm, Mike Conley mconl...@gmail.com wrote:
 And you do need to quote the column name in order_by also.

 session.query(func.sum(X.amount).label('tot_amount')).group_by(X.date).order_by('tot_amount').limit(10)

 generates code

 SELECT sum(x.amount) AS tot_amount
 FROM x GROUP BY x.date ORDER BY tot_amount
  LIMIT 10 OFFSET 0
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] column label and order by

2009-11-14 Thread rajasekhar911

Hi guys,

how do i apply order by on a column with a label.
My requirement is like this

class x
  id,
  amount,
  date

i have to group based on id and take sum of amount within a date
range.

i am applying a label to sum of amount
now how do i order based on that so that i can get top 5 ..

session.query( func.sum(x.amount).label('tot_amount'), x.id ).
filter(x.datefromdate).filter(x.datetodate).
.group_by(x.id)
.order_by(?)
.limit(5)


thanks.
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] a special relation

2009-10-14 Thread rajasekhar911

I have  a special kind of relation.

Relation = Table(relations, metadata,
Column('src_id',Unicode(50)),
Column('dest_id',Unicode(50)),
Column('relation',Unicode(50))
)

class Node(DeclarativeBase):
__tablename__ = 'nodes'

name = Column(Unicode(50), nullable=False)
node_id = Column(Unicode(50), primary_key=True)
children=relation('Node',secondary=Relation,\
primaryjoin=and_
(node_id==Relation.c.src_id,Relation.c.relation==u'Children'),\
foreign_keys=[Relation.c.src_id,Relation.c.dest_id],\
secondaryjoin=and_(Relation.c.dest_id==node_id),\
backref=backref('parent'))

this relation can be anything...children,friend,sibling
the query executed when i say node.children seems to be correct.
but my problem is when i add an object to this collection
only src_id and dest_id is populated.

i.e if i say node.children.append(xx) , i expect the relations table
to get
populated as
src_id=node.id ,
dest_id=xx.id
relation=u'Children'
but the relation column has value None.

how can i make SA to populate the relation column also?
PS:I checked Association Object, but couldn't figure out a way.

thnx for any help
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Declarative way of delete-orphan

2009-08-26 Thread rajasekhar911

Hi
How do i define a delete-orphan using declarative base?
I am using sqlite and SA0.5.5
I have defined a one to one relation.
class Child(DeclarativeBase):
__tablename__='children'
id=Column(String(50),primary_key=True)
parent_id=Column(String(50),ForeignKey
('parent.id',onupdate=CASCADE,ondelete=CASCADE))
name=Column(String(50))

class Parent(DeclarativeBase):
__tablename__='parent'
id=Column(String(50),primary_key=True)
name=Column(String(50))
children=relation('Child', uselist=False)

when i delete the parent it makes the parent_id None in Child.

I tried giving ondelete=DELETE according to
http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/schema.html#sqlalchemy.schema.ForeignKey
ondelete – Optional string. If set, emit ON DELETE value when
issuing DDL for this constraint. Typical values include CASCADE,
DELETE and RESTRICT.
But gave syntax error while trying to create the child table near
DELETE

I tried making parent_id as primarykey for Child.But that gave the
error Constraint tried to blank out the
PrimaryKey for instance

what am i doing wrong?
thnx in advance.
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: index in SA

2009-08-21 Thread rajasekhar911

i want to add a composite index to the class inherited from
declarative_base

I tried this,

class MyClass:
   __tablename__ = 'my_table'

id = Column(Integer, primary_key=True)
name = Column(String, nullable=False)
type = Column(String, nullable=False)
__table_args__ = (
Index('ix_name_type','name','type',unique=True)
)

gave me an error,
File /m2svn/trunk/src/model/MyClass.py, line 32, in MyClass
__table_args__ = (
  File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
sqlalchemy/schema.py, line 1461, in __init__
self._init_items(*columns)
  File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
sqlalchemy/schema.py, line 1465, in _init_items
self.append_column(_to_schema_column(column))
  File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
sqlalchemy/schema.py, line 2145, in _to_schema_column
raise exc.ArgumentError(schema.Column object expected)
sqlalchemy.exc.ArgumentError: schema.Column object expected


On Aug 21, 3:23 am, Michael Bayer mike...@zzzcomputing.com wrote:
 this is usually accomplished using Index().  see the metadata docs  
 for details.

 On Aug 20, 2009, at 12:35 PM, rajasekhar911 wrote:



  Hi

  Is it possible to add index to my table using sqlalchemy?
  Or should i do it directly on the database?

  Thanks..
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: index in SA

2009-08-21 Thread rajasekhar911

hi thanks for the reply..
but one doubt
how will i access the MyClass inside MyClass

i tried
ndex('ix_name_type',
MyClass.__table__.c.name,MyClass.__table__.c.type, unique=True)
it is giving the error
NameError: name 'MyClass' is not defined

thanks

On Aug 21, 2:04 pm, King Simon-NFHD78 simon.k...@motorola.com
wrote:
  -Original Message-
  From: sqlalchemy@googlegroups.com
  [mailto:sqlalch...@googlegroups.com] On Behalf Of rajasekhar911
  Sent: 21 August 2009 07:30
  To: sqlalchemy
  Subject: [sqlalchemy] Re: index in SA

  i want to add a composite index to the class inherited from
  declarative_base

  I tried this,

  class MyClass:
     __tablename__ = 'my_table'

      id = Column(Integer, primary_key=True)
      name = Column(String, nullable=False)
      type = Column(String, nullable=False)
      __table_args__ = (
              Index('ix_name_type','name','type',unique=True)
              )

  gave me an error,
  File /m2svn/trunk/src/model/MyClass.py, line 32, in MyClass
      __table_args__ = (
    File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
  sqlalchemy/schema.py, line 1461, in __init__
      self._init_items(*columns)
    File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
  sqlalchemy/schema.py, line 1465, in _init_items
      self.append_column(_to_schema_column(column))
    File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
  sqlalchemy/schema.py, line 2145, in _to_schema_column
      raise exc.ArgumentError(schema.Column object expected)
  sqlalchemy.exc.ArgumentError: schema.Column object expected

 I'm not sure if this is the root cause of your error, but __table_args__
 must either be a dictionary or a tuple where the last element is a
 dictionary (according 
 tohttp://www.sqlalchemy.org/docs/05/reference/ext/declarative.html#table-c
 onfiguration)

 Also, I think Index may require actual column parameters rather than
 strings (according 
 tohttp://www.sqlalchemy.org/docs/05/metadata.html#indexes). You may be
 able to use something like the following after your class definition:

   Index('ix_name_type', MyClass.__table__.c.name,
 MyClass.__table__.c.type, unique=True)

 or even

   Index('ix_name_type', MyClass.name, MyClass.type, unique=True)

 Hope that helps,

 Simon
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: index in SA

2009-08-21 Thread rajasekhar911

i tried

class MyClass:
   __tablename__ = 'my_table'

id = Column(Integer, primary_key=True)
name = Column(String, nullable=False)
type = Column(String, nullable=False)
__table_args__ = (
Index('ix_name_type', name , type ,unique=True)
)

it errors out

__table_args__ = (
  File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
sqlalchemy/schema.py, line 1461, in __init__
self._init_items(*columns)
  File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
sqlalchemy/schema.py, line 1465, in _init_items
self.append_column(_to_schema_column(column))
  File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
sqlalchemy/schema.py, line 1476, in append_column
self._set_parent(column.table)
  File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
sqlalchemy/schema.py, line 1469, in _set_parent
self.metadata = table.metadata
AttributeError: 'NoneType' object has no attribute 'metadata'

thanks

On Aug 21, 2:22 pm, rajasekhar911 rajasekhar...@gmail.com wrote:
 hi thanks for the reply..
 but one doubt
 how will i access the MyClass inside MyClass

 i tried
 ndex('ix_name_type',
 MyClass.__table__.c.name,MyClass.__table__.c.type, unique=True)
 it is giving the error
 NameError: name 'MyClass' is not defined

 thanks

 On Aug 21, 2:04 pm, King Simon-NFHD78 simon.k...@motorola.com
 wrote:

   -Original Message-
   From: sqlalchemy@googlegroups.com
   [mailto:sqlalch...@googlegroups.com] On Behalf Of rajasekhar911
   Sent: 21 August 2009 07:30
   To: sqlalchemy
   Subject: [sqlalchemy] Re: index in SA

   i want to add a composite index to the class inherited from
   declarative_base

   I tried this,

   class MyClass:
      __tablename__ = 'my_table'

       id = Column(Integer, primary_key=True)
       name = Column(String, nullable=False)
       type = Column(String, nullable=False)
       __table_args__ = (
               Index('ix_name_type','name','type',unique=True)
               )

   gave me an error,
   File /m2svn/trunk/src/model/MyClass.py, line 32, in MyClass
       __table_args__ = (
     File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
   sqlalchemy/schema.py, line 1461, in __init__
       self._init_items(*columns)
     File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
   sqlalchemy/schema.py, line 1465, in _init_items
       self.append_column(_to_schema_column(column))
     File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
   sqlalchemy/schema.py, line 2145, in _to_schema_column
       raise exc.ArgumentError(schema.Column object expected)
   sqlalchemy.exc.ArgumentError: schema.Column object expected

  I'm not sure if this is the root cause of your error, but __table_args__
  must either be a dictionary or a tuple where the last element is a
  dictionary (according 
  tohttp://www.sqlalchemy.org/docs/05/reference/ext/declarative.html#table-c
  onfiguration)

  Also, I think Index may require actual column parameters rather than
  strings (according 
  tohttp://www.sqlalchemy.org/docs/05/metadata.html#indexes). You may be
  able to use something like the following after your class definition:

    Index('ix_name_type', MyClass.__table__.c.name,
  MyClass.__table__.c.type, unique=True)

  or even

    Index('ix_name_type', MyClass.name, MyClass.type, unique=True)

  Hope that helps,

  Simon
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: index in SA

2009-08-21 Thread rajasekhar911

exactly

On Aug 21, 2:33 pm, King Simon-NFHD78 simon.k...@motorola.com
wrote:
  -Original Message-
  From: sqlalchemy@googlegroups.com
  [mailto:sqlalch...@googlegroups.com] On Behalf Of rajasekhar911
  Sent: 21 August 2009 10:25
  To: sqlalchemy
  Subject: [sqlalchemy] Re: index in SA

  i tried

  class MyClass:
     __tablename__ = 'my_table'

      id = Column(Integer, primary_key=True)
      name = Column(String, nullable=False)
      type = Column(String, nullable=False)
      __table_args__ = (
              Index('ix_name_type', name , type ,unique=True)
              )

  it errors out

  __table_args__ = (
    File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
  sqlalchemy/schema.py, line 1461, in __init__
      self._init_items(*columns)
    File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
  sqlalchemy/schema.py, line 1465, in _init_items
      self.append_column(_to_schema_column(column))
    File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
  sqlalchemy/schema.py, line 1476, in append_column
      self._set_parent(column.table)
    File /usr/lib/python2.4/site-packages/SQLAlchemy-0.5.5-py2.4.egg/
  sqlalchemy/schema.py, line 1469, in _set_parent
      self.metadata = table.metadata
  AttributeError: 'NoneType' object has no attribute 'metadata'

  thanks

 The problem is that at the time you are calling Index, the table
 object doesn't exist. Apparently the Index object doesn't work with
 declarative in this way.

 However, if you just move your Index definition outside the class
 definition completely, I think it should be fine.

 ie.

 class MyClass(Base):
    __tablename__ = 'my_table'

     id = Column(Integer, primary_key=True)
     name = Column(String, nullable=False)
     type = Column(String, nullable=False)

 Index('ix_name_type', MyClass.name, MyClass.type, unique=True)

 Simon
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] index in SA

2009-08-20 Thread rajasekhar911

Hi

Is it possible to add index to my table using sqlalchemy?
Or should i do it directly on the database?

Thanks..
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: AttributeError: 'NoneType' object has no attribute 'dict'

2009-08-02 Thread rajasekhar911

the error can be reproduced by adding __getattr__ method to the model
class.
my model class has some attributes that are lazy initialized and are
not mapped to any table columns.
i am using the getattr method to implement the lazy initialization.

On Jul 31, 6:15 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 theres no way to know unless you can illustrate how to reproduce the  
 issue fully.      one hunch is that your mappers are not compiled (try  
 calling compile_mappers()).

 On Jul 31, 2009, at 3:39 AM, rajasekhar911 wrote:



  is it because of lazy initialization?
  I have some other attributes in my class which are lazy initialized.
  But these are not mapped to columns.

  On Jul 31, 11:44 am, rajasekhar911 rajasekhar...@gmail.com wrote:
  i have upgraded to 0.5.5
  Now the error changed to
  AttributeError: 'NoneType' object has no attribute 'modified_event'
  Module sqlalchemy.orm.attributes:150 in __set__          view
        def __set__(self, instance, value):
                 self.impl.set(instance_state(instance), instance_dict
  (instance), value, None)

             def __delete__(self, instance):  
  self.impl.set(instance_state(instance), instance_dict(instance),  
  value, None)

  Module sqlalchemy.orm.attributes:447 in set         view
            else:
                     old = dict_.get(self.key, NO_VALUE)
                 state.modified_event(dict_, self, False, old)

                 if self.extensions:  state.modified_event(dict_,  
  self, False, old)

  AttributeError: 'NoneType' object has no attribute 'modified_event'

  it seems instance_state(instance) returns None.

  On Jul 30, 7:51 pm, Michael Bayer mike...@zzzcomputing.com wrote:

  theres nothing about the given code that should cause any issue  
  (and I
  tried it on 0.5.1).    Upgrade to 0.5.5 in any case and that will  
  almost
  certainly resolve the issue.

  rajasekhar911 wrote:

  I am using declarative method to map objects.
  I am getting the following error when i try to create the object

  My Class is
  from sqlalchemy.ext.declarative import declarative_base
  DeclarativeBase = declarative_base()
  class User(DeclarativeBase):
      __tablename__='managed_nodes'
      id = Column(String(50), primary_key=True)
      username=Column(String(50))

  def __init__(self,username = None,id = None):
          self.username = username
          if not id:
              self.id  = username
          else:
              self.id = id

  u = User(username='xxx')

  Module model.User:63 in __init__
            self.username = username

       self.username = username
  Module sqlalchemy.orm.attributes:151 in __set__         view
        def __set__(self, instance, value):
                 self.impl.set(instance_state(instance), value, None)

             def __delete__(self, instance):
   self.impl.set(instance_state(instance), value, None)
  Module sqlalchemy.orm.attributes:440 in set         view
                old = self.get(state)
                 else:
                     old = state.dict.get(self.key, NO_VALUE)

                 state.modified_event(self, False, old)
   old = state.dict.get(self.key, NO_VALUE)
  AttributeError: 'NoneType' object has no attribute 'dict'

  what can be the possible reason??
  my sqlalchemy version is 0.5.1 on centos5.2...
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: AttributeError: 'NoneType' object has no attribute 'dict'

2009-07-31 Thread rajasekhar911

i have upgraded to 0.5.5
Now the error changed to
AttributeError: 'NoneType' object has no attribute 'modified_event'
Module sqlalchemy.orm.attributes:150 in __set__  view
  def __set__(self, instance, value):
   self.impl.set(instance_state(instance), instance_dict
(instance), value, None)

   def __delete__(self, instance):
  self.impl.set(instance_state(instance), instance_dict(instance), value, 
 None)
Module sqlalchemy.orm.attributes:447 in set view
  else:
   old = dict_.get(self.key, NO_VALUE)
   state.modified_event(dict_, self, False, old)

   if self.extensions:
  state.modified_event(dict_, self, False, old)
AttributeError: 'NoneType' object has no attribute 'modified_event'

it seems instance_state(instance) returns None.



On Jul 30, 7:51 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 theres nothing about the given code that should cause any issue (and I
 tried it on 0.5.1).    Upgrade to 0.5.5 in any case and that will almost
 certainly resolve the issue.

 rajasekhar911 wrote:

  I am using declarative method to map objects.
  I am getting the following error when i try to create the object

  My Class is
  from sqlalchemy.ext.declarative import declarative_base
  DeclarativeBase = declarative_base()
  class User(DeclarativeBase):
      __tablename__='managed_nodes'
      id = Column(String(50), primary_key=True)
      username=Column(String(50))

  def __init__(self,username = None,id = None):
          self.username = username
          if not id:
              self.id  = username
          else:
              self.id = id

  u = User(username='xxx')

  Module model.User:63 in __init__
            self.username = username

       self.username = username
  Module sqlalchemy.orm.attributes:151 in __set__         view
        def __set__(self, instance, value):
                 self.impl.set(instance_state(instance), value, None)

             def __delete__(self, instance):
   self.impl.set(instance_state(instance), value, None)
  Module sqlalchemy.orm.attributes:440 in set         view
                old = self.get(state)
                 else:
                     old = state.dict.get(self.key, NO_VALUE)

                 state.modified_event(self, False, old)
   old = state.dict.get(self.key, NO_VALUE)
  AttributeError: 'NoneType' object has no attribute 'dict'

  what can be the possible reason??
  my sqlalchemy version is 0.5.1 on centos5.2...
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: AttributeError: 'NoneType' object has no attribute 'dict'

2009-07-31 Thread rajasekhar911

is it because of lazy initialization?
I have some other attributes in my class which are lazy initialized.
But these are not mapped to columns.

On Jul 31, 11:44 am, rajasekhar911 rajasekhar...@gmail.com wrote:
 i have upgraded to 0.5.5
 Now the error changed to
 AttributeError: 'NoneType' object has no attribute 'modified_event'
 Module sqlalchemy.orm.attributes:150 in __set__          view
       def __set__(self, instance, value):
                self.impl.set(instance_state(instance), instance_dict
 (instance), value, None)

            def __delete__(self, instance):  
 self.impl.set(instance_state(instance), instance_dict(instance), value, None)

 Module sqlalchemy.orm.attributes:447 in set         view
           else:
                    old = dict_.get(self.key, NO_VALUE)
                state.modified_event(dict_, self, False, old)

                if self.extensions:  state.modified_event(dict_, self, 
 False, old)

 AttributeError: 'NoneType' object has no attribute 'modified_event'

 it seems instance_state(instance) returns None.

 On Jul 30, 7:51 pm, Michael Bayer mike...@zzzcomputing.com wrote:

  theres nothing about the given code that should cause any issue (and I
  tried it on 0.5.1).    Upgrade to 0.5.5 in any case and that will almost
  certainly resolve the issue.

  rajasekhar911 wrote:

   I am using declarative method to map objects.
   I am getting the following error when i try to create the object

   My Class is
   from sqlalchemy.ext.declarative import declarative_base
   DeclarativeBase = declarative_base()
   class User(DeclarativeBase):
       __tablename__='managed_nodes'
       id = Column(String(50), primary_key=True)
       username=Column(String(50))

   def __init__(self,username = None,id = None):
           self.username = username
           if not id:
               self.id  = username
           else:
               self.id = id

   u = User(username='xxx')

   Module model.User:63 in __init__
             self.username = username

        self.username = username
   Module sqlalchemy.orm.attributes:151 in __set__         view
     def __set__(self, instance, value):
                  self.impl.set(instance_state(instance), value, None)

              def __delete__(self, instance):
    self.impl.set(instance_state(instance), value, None)
   Module sqlalchemy.orm.attributes:440 in set         view
             old = self.get(state)
                  else:
                      old = state.dict.get(self.key, NO_VALUE)

                  state.modified_event(self, False, old)
    old = state.dict.get(self.key, NO_VALUE)
   AttributeError: 'NoneType' object has no attribute 'dict'

   what can be the possible reason??
   my sqlalchemy version is 0.5.1 on centos5.2...
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] AttributeError: 'NoneType' object has no attribute 'dict'

2009-07-30 Thread rajasekhar911

I am using declarative method to map objects.
I am getting the following error when i try to create the object

My Class is
from sqlalchemy.ext.declarative import declarative_base
DeclarativeBase = declarative_base()
class User(DeclarativeBase):
__tablename__='managed_nodes'
id = Column(String(50), primary_key=True)
username=Column(String(50))

def __init__(self,username = None,id = None):
self.username = username
if not id:
self.id  = username
else:
self.id = id

u = User(username='xxx')

Module model.User:63 in __init__
  self.username = username

  self.username = username
Module sqlalchemy.orm.attributes:151 in __set__ view
  def __set__(self, instance, value):
   self.impl.set(instance_state(instance), value, None)

   def __delete__(self, instance):
  self.impl.set(instance_state(instance), value, None)
Module sqlalchemy.orm.attributes:440 in set view
  old = self.get(state)
   else:
   old = state.dict.get(self.key, NO_VALUE)

   state.modified_event(self, False, old)
  old = state.dict.get(self.key, NO_VALUE)
AttributeError: 'NoneType' object has no attribute 'dict'

what can be the possible reason??
my sqlalchemy version is 0.5.1 on centos5.2...
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] single table inheritance through declarative.

2009-07-29 Thread rajasekhar911

Hi

I am facing a different problem in inheritance.
I am using the single table inheritance through declarative.
http://www.sqlalchemy.org/docs/05/reference/ext/declarative.html#single-table-inheritance

b=Base()
b.id='xxx'
b.name='xxx'
b.type='type1'
I am manually setting the type column of my base class.
but when i try to commit,it gives the IntegrityError
base.type may not be NULL u'INSERT INTO bases (id, name, type,
address, login, password) VALUES (?, ?, ?, ?, ?, ?)' ['xxx', 'xxx',
None, None, 'xxx','xxx']

I checked this thread, 
http://groups.google.com/group/sqlalchemy/browse_thread/thread/c646007dce37b11a
but I dont have access to the subclass to set the __class__


--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] relationship between multiple tables in single table

2009-07-06 Thread rajasekhar911

I have 4 tables tbl1, tbl2, tbl3  tbl4.
There are OTM  MTM (parent-child , friend ...) relations between
these tables.
Right now each relation has its own MTM table.
like tbl1_tbl2, tbl1_tbl3, tbl2_tbl3, tbl3_tbl4, tbl2_tbl4.
Is there a way to put all these relations into single table called
tbl_relations
and still be able to call tbl1.children, tbl1.friends , tbl2.children,
tbl2.parent ...

Is there a way to make sqlachemy to work with this?

--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---