hello all,

I am newbie in sqlalchemy.I am thrilled by the sqlachemy features. But i got
struck in the how to write the not null  for the following:

create table organisation(orgcode varchar(30) not null,orgname text not
null,primary key(orgcode));

I have written the using declarative base as follows but dont know how to
impose not null constraint

from sqlalchemy import create_engine
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker,scoped_session

engine = create_engine('postgresql:///gkanusha', echo=False)
Base = declarative_base()
class Organisation(Base):
    __tablename__ = 'Organisation'
    orgcode = Column(String,primary_key=True)
    orgname = Column(String)
    def __init__(self,orgcode,orgname):
        self.orgcode = orgcode
        self.orgname = orgname

organisation_table = Organisation.__table__

metadata = Base.metadata
metadata.create_all(engine)
Session = scoped_session(sessionmaker(bind=engine))
Session.commit()

There are other columns also but i have taken two columns for simplicity.

Thanks in advance
-- 


Njoy the share of Freedom :)
Anusha Kadambala

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

Reply via email to