Skip to content

Instantly share code, notes, and snippets.

@msaisushma
Created April 11, 2014 12:02
Show Gist options
  • Save msaisushma/10462512 to your computer and use it in GitHub Desktop.
Save msaisushma/10462512 to your computer and use it in GitHub Desktop.
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
Base = declarative_base()
class BusRoute(Base):
__tablename__ = 'busroutes'
bus_no = Column(Integer, primary_key=True)
start_point = Column(String(100))
end_point = Column(String(100))
route = Column(String(200))
def __businfo__(self):
return "<BusClass(start_point='%s', end_point='%s', route='%s')>" % (
self.start_point, self.end_point, self.route)
@nandak522
Copy link

I dont see any problem with this.

>>> from sqlalchemy.ext.declarative import declarative_base
>>> from sqlalchemy import Column, Integer, String
>>>  
>>> Base = declarative_base()
>>>  
>>> class BusRoute(Base):
...     __tablename__ = 'busroutes'
...     bus_no = Column(Integer, primary_key=True)
...     start_point = Column(String(100))
...     end_point = Column(String(100))
...     route = Column(String(200))
...  
...     def __businfo__(self):
...         return "<BusClass(start_point='%s', end_point='%s', route='%s')>" % (
...                              self.start_point, self.end_point, self.route)
... 
>>> 
>>> 
>>> businfo=BusRoute(start_point='m',end_point='u',route='lalbagh')
>>> businfo
<BusRoute object at 0xa91baac>
>>> businfo.__businfo__()
"<BusClass(start_point='m', end_point='u', route='lalbagh')>"
>>> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment