Re: [sqlalchemy] newbie to sqlalchemy :not null constraint

2010-02-10 Thread anusha kadambala
Thanks, Micheal for your help


On Wed, Feb 10, 2010 at 9:53 AM, Michael Trier mtr...@gmail.com wrote:


  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

 You want to use the nullable=False argument.


 http://www.sqlalchemy.org/docs/reference/sqlalchemy/schema.html?highlight=nullable

 Thanks,

 Michael

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




-- 


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.



[sqlalchemy] newbie to sqlalchemy :not null constraint

2010-02-09 Thread anusha kadambala
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.



Re: [sqlalchemy] newbie to sqlalchemy :not null constraint

2010-02-09 Thread Michael Trier

 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

You want to use the nullable=False argument.

http://www.sqlalchemy.org/docs/reference/sqlalchemy/schema.html?highlight=nullable

Thanks,

Michael

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