django-orm创建数据
方案1
python manage.py shell
In [3]: b1=Book.objects.create(title='python',pub='清华大学出版社',price=20,mar
...: ket_price=25)
In [4]: b1
Out[4]: <Book: Book object (1)>
#数据库中
mysql> select * from book;
+----+--------+-------+--------------+----------------+
| id | title | price | market_price | pub |
+----+--------+-------+--------------+----------------+
| 1 | python | 20.00 | 25.00 | 清华大学出版社 |
+----+--------+-------+--------------+----------------+
1 row in set (0.07 sec)
方案2
In [5]: b2=Book(title='Django',pub='清华大学出版社',price=70,market_price=75)
In [6]: b2.save()
mysql> select * from book;
+----+--------+-------+--------------+----------------+
| id | title | price | market_price | pub |
+----+--------+-------+--------------+----------------+
| 1 | python | 20.00 | 25.00 | 清华大学出版社 |
| 2 | Django | 70.00 | 75.00 | 清华大学出版社 |
+----+--------+-------+--------------+----------------+
2 rows in set (0.00 sec)