how to access SQLAlchemy to Django Model ?

25 views
Skip to first unread message

Ramin Farajpour Cami

unread,
Dec 21, 2015, 6:34:04 AM12/21/15
to Django users
Basic Models (Django and SQLAlchemy):
A basic Django model looks something like this:

class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
The equivalent SQLAlchemy model with declarative base looks like this:


from sqlalchemy import Column, Integer, String
class Person(Base):
__tablename__ = 'persons'
id = Column(Integer, primary_key=True)
first_name = Column(String(30))
last_name = Column(String(30))

Reply all
Reply to author
Forward
0 new messages