>>> cur.execute(
... """INSERT INTO some_table (an_int, a_date, a_string)
... VALUES (%s, %s, %s);""",
... (10, datetime.date(2005, 11, 18), "O'Reilly"))
is converted into the SQL command:
INSERT INTO some_table (an_int, a_date, a_string)
VALUES (10, '2005-11-18', 'O''Reilly');
>>> cur.execute(
... """INSERT INTO some_table (an_int, a_date, another_date, a_string)
... VALUES (%(int)s, %(date)s, %(date)s, %(str)s);""",
... {'int': 10, 'str': "O'Reilly", 'date': datetime.date(2005, 11, 18)})
class School(models.Model):
name = models.CharField(max_length=200)
address = models.CharField(max_length=200)
class MyUser(AbstractBaseUser):
GROUP_DIRECT = 0
GROUP_TEACHER = 1
# ...
GROUP_PARENT = 8
GROUP_STUDENT = 9
GROUP = (
(GROUP_DIRECT, 'Director'),
(GROUP_TEACHER, 'Teacher'),
# ...
(GROUP_PARENT, 'Parent'),
(GROUP_STUDENT, 'Student'),
)
name = models.CharField(max_length=200)
email = models.EmailField()
group = models.IntegerField(choices=GROUP)
class Lesson(models.Model):
name = models.CharField(max_length=200)
# ...
school = models.ForeignKey(School)
class Director(MyUser):
description = models.CharField(max_length=200)
# ...
school = models.ForeignKey(School)
class Teacher(MyUser):
description = models.CharField(max_length=200)
# ...
school = models.ForeignKey(School)
class Student(MyUser):
description = models.CharField(max_length=200)
# ...
school = models.ForeignKey(School)
class Parent(MyUser):
description = models.CharField(max_length=200)
children = models.ManyToManyField(Student)
# ...
Чем мне грозит такой рост БД?ничем. Вероятность, что у тебя внезапно появятся 10^6 пользователей, которые наплодят 10^12 постов и у тебя еще не будет денег на комманду - ничтожно мала