On 1 Sep 2013, at 18:27, Mohsen Pahlevanzadeh <[email protected]> wrote:
> Dear all, > > Before apply code or writing code from a documentation, At first i test it > into test.py, > Now ,I read the following doc: > conjuctions in sqlalchemy > > I supposed users a class such as tables class: > ////////////////////// > class users(declarative_base(bind=engine)): > > __tablename__ = 'users'; # > id = Column(Integer,primary_key = True) > name = Column(String) > name_type = Column(Integer) > addresses = Column(String) > telephones = Column(String) > emails = Column(String) > ////////////////// > > But i didn't understand c variable. Object or otehr variable such : > /////////////// > addresses.c.email_address or users.c.id == addresses.c.user_id > ///////////////// > > > If possible explain c object. The SQLAlchemy library has 2 main parts. The lower layer is known as the Core API, and works with Table objects: http://docs.sqlalchemy.org/en/rel_0_8/core/tutorial.html#define-and-create-tables Table objects have a "columns" attribute (which is usually abbreviated to "c") which gives you access to the columns of the table: http://docs.sqlalchemy.org/en/rel_0_8/core/metadata.html#accessing-tables-and-columns Table objects also have lots of other methods, such as ones for creating SELECT, UPDATE and DELETE statements, and so on. The ORM is built on top of the Core API. When you create classes that inherit from a declarative_base class, you are creating a "mapped class". Mapped classes don't have a "c" attribute because you can access the columns directly from the class itself. To perform SELECT, UPDATE and DELETE statements on these classes, you use the Session and Query objects. If you ever need the underlying Table object, you can get it from your mapped class via the "__table__" attribute, but most of the time you don't need it. Hope that helps, Simon -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.
