On Wed, 2009-11-25 at 21:00 +0200, Nikolai Drozd wrote:
> > 
> > from sqlalchemy.ext.declarative import declarative_base
> > base = declarative_base(meta.metadata)
> 
> That seems to be correct. At least it works in my project :)
> 
Then I believe it should be correct.

> > 
> > if Yes then how can I create instances of any table inside a control?
> 
> What do you mean by instance of a table?

Ok here is a simple class which I created in my __init__.py file
in /model given the imports I am making specific to declarative_base. 

class members(base):
        __tablename__ = "person"
        id = sa.Column(sa.types.Integer, primary_key = True)
        membername = sa.Column(sa.types.String(250))
        address = sa.Column(sa.types.String(300))

Let's say in my control I want to add record to this table by getting
values from a request.
Another method in the same control would like to query for all the
members in the table and send the result out as a c.records to be then
rendered into a mako template for form generation using for example
webhelpers.

My question is how can I use the above class to add records and how can
I query the table for records.

The major point of confusion is about the session object.

Where is the actual Session instance?  will I have to do some thing like
base.Session or just Session will work?

Same goes for making an instance of a member class for adding records
for example.
should I use the following line?
newMember = model.members.__table__
or is there some thing else I must do?

Happy hacking.
Krishnakant.


--

You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.


Reply via email to