Basic Models (Django and SQLAlchemy):
A basic Django model looks something like this:
-- 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:
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))
class Person(Base):
__tablename__ = 'persons'
id = Column(Integer, primary_key=True)
first_name = Column(String(30))
last_name = Column(String(30))
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2918070b-8ded-4927-b799-7b0f4139d5df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment