A semantic search engine for source code https://bitshift.benkurtovic.com/
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

40 líneas
933 B

  1. """
  2. Module with classes and functions to handle communication with the MySQL
  3. database backend, which manages the search index.
  4. """
  5. import mmh3
  6. import oursql
  7. class Database(object):
  8. """Represents the MySQL database."""
  9. def __init__(self):
  10. self._connect()
  11. def _connect(self):
  12. """Establish a connection to the database."""
  13. self._conn = oursql.connect()
  14. def search(self, query):
  15. """
  16. Search the database.
  17. :param query: The query to search for.
  18. :type query: :py:class:`~.query.tree.Tree`
  19. :return: A list of search results.
  20. :rtype: list of :py:class:`.Codelet`\ s
  21. """
  22. pass
  23. def insert(self, codelet):
  24. """
  25. Insert a codelet into the database.
  26. :param codelet: The codelet to insert.
  27. :type codelet: :py:class:`.Codelet`
  28. """
  29. # code_hash = mmh3.hash64(codelet.code)[0]
  30. pass