title: How "dict_factory(cursor, row)" is called automatically from "dict_factory" while i am not passing any parameters?
body: <p>I am very new to python development and having trouble while understanding one method used in one sample, the method is:</p>
  
  <pre><code>def dict_factory(cursor, row):
  
      d={}
      for idx, col in enumerate(cursor.description):
          d[col[0]] = row[idx]
  
      return d
  </code></pre>
  
  <p>and it is being called from:</p>
  
  <pre><code>conn = sqlite3.connect("books.db")
  conn.row_factory = dict_factory
  cur = conn.cursor()
  </code></pre>
  
  <p>Now the 2 questions are:</p>
  
  <ol>
  <li><p>How dict_factory(cursor, col) is being called from dict_factory without params?</p></li>
  <li><p>How dict_factory() is actually working? Does enumerate breaks the DB into the format of (c0,r0),(c0,r1) and so on?</p></li>
  </ol>
  
  <p>The converted DB by dict_factory is:</p>
  
  <pre><code>[
    {
      "author": "Ann Leckie ", 
      "first_sentence": "The body lay naked and facedown, a deathly gray, spatters of blood staining the snow around it.", 
      "id": null, 
      "published": 2014, 
      "title": "Ancillary Justice"
    }, 
    {
      "author": "John Scalzi", 
      "first_sentence": "From the top of the large boulder he sat on, Ensign Tom Davis looked across the expanse of the cave, toward Captain Lucius Abernathy, Science Officer Q\u2019eeng and Chief Engineer Paul West perched on a second, larger boulder, and thought, Well, this sucks.", 
      "id": null, 
      "published": 2013, 
      "title": "Redshirts"
    }
  ]
  </code></pre>