[sqlalchemy] Re: How to get list of relations

2007-10-29 Thread Wes Duff
Hey whats going on.
I am a new sqlalchemist as well but lets see if this helps any.

This is how I am getting a list of all names that corrispond with my
document names class.

names = [ c.name for c in model.Document.select_by(param=param) ]
So I am just collecting all the names from my Document table. I added
select_by(param=param) if you want to find all the names that have to do
with a parameter.
names becomes a list

I hope this helps a little.


On Oct 29, 2007 11:21 AM, Paul Johnston [EMAIL PROTECTED] wrote:

 Hi,

 How do I get a list of the relations a mapper has? I've been using
 mapper.properties, but have just realised this doesn't pick up backrefs.

 Any ideas? Thanks,

 Paul

 


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



[sqlalchemy] Re: multiple inserts of sqlalchemy instances?

2007-10-23 Thread Wes Duff
I have done something like this.
I am using active mapper. I am new to all of this as well, but see if this
helps any

a = model.Document()
a.first_name = kw.get('first_name')
a.last_name = kw.get('last_name')

b = model.Body()
b.body_name = kw.get('body_name')

And that is all I was doing
of cource you need to make the form with the inputs for first, last, and
body name and assign **kw to your dict()

That is how I have been assigning multiple items during one run.

I am by no means an expert, just thought this might help

On 10/23/07, Lukasz Szybalski [EMAIL PROTECTED] wrote:


 On 10/23/07, Michael Bayer [EMAIL PROTECTED] wrote:
 
 
  On Oct 23, 2007, at 10:16 AM, Lukasz Szybalski wrote:
 
  
   I am having an issue with a second  new.flush()
   Does this require multiple sessions for each save?
  
   I can't find any documentation on multiple inserts with assign_mapper.
   Lucas
  
 
  Your best bet is to use version 0.4 and to not use any extensions
  such as assign_mapper.

 So you cannot do multiple writes using extensions assign_mapper,
 mapper aka python class mapped to sql table?

 What I should use then is
 user_table = sqlalchemy.Table('Users', metadata, autoload=True)
 new=users_table.insert()


 and new.execute(somedictionary,somedictionary2)
 or
 new.execute(somedictionary)
 #change somedictionary
 new.execute(somedictionary)

 Thanks,
 Lucas

 


--~--~-~--~~~---~--~~
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] ActiveMapper -- Questions - NEED DOCUMENTATION

2007-10-23 Thread Wes Duff
Hello, I was wondering if anyone can tell me how to access a column using
active mapper.
Or maybe you might know of a good documentational site for ActiveMapper?

Here is a table example

class Document(ActiveMapper):
   class mapping:
   __table__='document'
   id = column(Integer, primary_key=True)
   title = column(Unicode)
   name = column(Unicode)

This is not my real table I am using just an example.

How can I access title in my controller

Would it be:

a = model.Document.document.c.title

or

a = model.Document.title

or

a = model.Docment.c.title

or

a = model.Doucment.table.c.title

I am not sure.

Would also help if there were some good documentation out there for
ActiveMapper.

P.S. I cannot change to something else. I must stay with ActiveMapper

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: ActiveMapper -- Questions - NEED DOCUMENTATION

2007-10-23 Thread Wes Duff
I am working for a company right now that has all of thier database items on
Active Mapper. I would love to change to something with more documentation.
We plan on changing soon, but for right now I have to get this working.

Thanks


On 10/23/07, Michael Bayer [EMAIL PROTECTED] wrote:



 On Oct 23, 2007, at 4:42 PM, Wes Duff wrote:

  a = model.Docment.c.title
 

 should be that one

  Would also help if there were some good documentation out there for
  ActiveMapper.
 
  P.S. I cannot change to something else. I must stay with ActiveMapper

 ActiveMapper is unmaintained.  I can't imagine why you couldn't
 switch from it to plain mappers or Elixir.

 


--~--~-~--~~~---~--~~
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: ActiveMapper -- Questions - NEED DOCUMENTATION

2007-10-23 Thread Wes Duff
Thanks alot for your info.

Much appreciated.


On 10/23/07, Wes Duff [EMAIL PROTECTED] wrote:

 I am working for a company right now that has all of thier database items
 on Active Mapper. I would love to change to something with more
 documentation. We plan on changing soon, but for right now I have to get
 this working.

 Thanks


  On 10/23/07, Michael Bayer [EMAIL PROTECTED] wrote:
 
 
 
  On Oct 23, 2007, at 4:42 PM, Wes Duff wrote:
 
   a = model.Docment.c.title
  
 
  should be that one
 
   Would also help if there were some good documentation out there for
   ActiveMapper.
  
   P.S. I cannot change to something else. I must stay with ActiveMapper
 
  ActiveMapper is unmaintained.  I can't imagine why you couldn't
  switch from it to plain mappers or Elixir.
 
   
 


--~--~-~--~~~---~--~~
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] Basic Level 1 sqlalchemist

2007-10-10 Thread Wes Duff
Hello gentelmen and ladies,

I am very new to sqlalchemy and put in a position where I had to jump out of
and airplane and land on my head and walk on my hands to the end of this
project.

I wanted to know how one_to_man and many_to_many are carried out.

Here is an example

class Document(ActiveMapper):
class mapping:
__table__= 'document'
id = column(Integer, primary_key=True)
title = column(Unicode)
shortdesc_dc = column(Unicode, nullable=True)

doc_type_id = column(Integer, foreign_key=ForeignKey('doc_type.id'))
layout_id = column(Integer, foreign_key=ForeignKey('layout.id'))
body_id = column(Integer, foreign_key=ForeignKey('body.id'))

dochists = one_to_many('DocumentHistory', colname='doc_id',
backref='document')
doctags = many_to_many('DocTag', document_doc_tag_table,
backref='document')



Does this mean that there is one document to many DocumentHistory. If so
that is what I need

And below is the DocumentHistory section


class DocumentHistory(ActiveMapper):
class mapping:
__table__= 'document_hist'
id = column(Integer, primary_key=True)
user_guid = column(Integer, nullable=True)
timestamp = column(TIMESTAMP, nullable=False)
rev_num = column(Integer, nullable=True)
change = column(Unicode, nullable=True)

doc_id = column(CHAR(32), foreign_key=ForeignKey('document.id'))


Thanks for your help. Some day I will repay the group with my knowlege.

Wes Duff

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