class_docstr: Establishes a connection to the database and returns an open cursor.
  # Use as context manager
  with Cursor() as cur:
      cur.execute(query)
      ...
class_docstr_tok: ["Establishes","a","connection","to","the","database","and","returns","an","open","cursor",".","#","Use","as","context","manager","with","Cursor","(",")","as","cur",":","cur.execute","(","query",")","..."]
code: def __init__(self, dictionary=False, **options):
      super().__init__()
  
      self._cache = queue.Queue(maxsize=5)
  
      try:
          conn = self._cache.get_nowait()
          # Ping the connection before using it from the cache.
          conn.ping(True)
      except queue.Empty:
          conn = psycopg2.connect(**options)
  
      self.conn = conn
      self.dictionary = dictionary
  
file_path: dejavu/dejavu/database_handler/postgres_database.py
imports: import queue
  import psycopg2
  from psycopg2.extras import DictCursor
  from dejavu.base_classes.common_database import CommonDatabase
  from dejavu.config.settings import FIELD_FILE_SHA1, FIELD_FINGERPRINTED, FIELD_HASH, FIELD_OFFSET, FIELD_SONG_ID, FIELD_SONGNAME, FIELD_TOTAL_HASHES, FINGERPRINTS_TABLENAME, SONGS_TABLENAME
label_desc: Use image node_id 1 to create a new Cursor object from inherited base classes: object with example: obj = Cursor(dictionary)