djangoQ query, ORM query optimization, transactions, common fields, three types of many-to-many, Ajax
Table of contents Today’s content details Q query advanced operations ORM Query Optimization ORM Transaction Operations ORM Common Field Types ORM Common Fields Parameters Ajax Content-Type ajax carries file data Today’s content details Q query advanced operation from django.db.models import Qq_obj = Q() # 1. Generate q objectq_obj.cOnnector= ‘or’ # The default connection of multiple conditions is and and can be modified as orq_obj.children.append((‘pk’, 1)) # 2. Add query conditionsq_obj.children.append((‘price__gt’, 2000 )) # Support adding multiple res = models.Book.objects.filter(q_obj) # Query supports directly filling in q objectsprint(res) ORM query optimization 1.ORM queries are lazy queries by default2.ORM queries come with Pagination processing3.only and defer ”’data object + data corresponding to the specified field”’ # res = models.Book.objects.only(‘title’, ‘price’) # print(res) # queryset [data object, data object] # for obj in res: # print(obj.title) # Click on the field filled in the brackets without entering the SQL query # print(obj.price) # print(obj.publish_time) # You can click on the fields not in the brackets to get the data but you can use SQL query res = models.Book.objects.defer(‘title ‘, ‘price’) # print(res) # queryset [data object, data object] for obj in res: # print(obj.title) # Click on the field filled in the brackets…
[JAVAEE study notes] hibernate02: entity rules, object status, cache, transactions, batch query and customer list display
android asp.net php jsp Database java Caching get windows Write your review! Come on, watch it all Member login | User registration Recommended reading get Hide and show problems”>Use radio to control ’s hiding and display problems Problems with hiding and displaying”><img src="https://img.php1.cn/3cd4a/1eebe/cd5/21e585a7e21fc7dc.png" width="120" height="70" alt="Use radio control Hide and show issues”/> jsp page code 1 2[Details] Crayon Shin-chan 2023-09-25 14:14:00 get android log file LogUtils instance_Android This article mainly introduces the android log file LogUtils example, which has good reference value and hopes to be helpful to everyone. one … [detailed] Crayon Shin-chan 2023-09-25 14:56:57
A simple understanding of MySQL locks, transactions, and MVCC
mysql TutorialThe column introduces a simple understanding of MySQL locks, transactions, and MVCC. How does MySQL implement ACID for transactions? The transaction has the four characteristics of ACID, so how does MySQL implement these four attributes of the transaction? Atomicity Either all succeed, or all fail. MySQL achieves atomicity by recording undo_log. undo_log is rollback log, write undo_log to disk before real SQL execution, and then Operate on database data. If an exception or rollback occurs, the reverse operation can be performed according to the undo_log to restore the data as it was before the transaction was executed. persistent sex Once a transaction is committed normally, its effect on the database should be permanent. At this time, even if the system crashes, the modified data will not be lost. As the storage engine of MySQL, InnoDB stores data on disk, but if disk IO is required for every read and write data, the efficiency will be very low. To this end, InnoDB provides a cache (Buffer Pool) as a buffer for accessing the database: when reading data from the database, it will first read from the Buffer Pool, if there is no Buffer Pool, it will be read from the…