<commit_before>defmodule Mssqlex do
  alias Mssqlex.Query
  @moduledoc """
  Documentation for Mssqlex.
  """

  @doc """
  Connect to a MS SQL Server using ODBC.

  ## Options

    * `:odbc_driver` - The driver ODBC will use (default: {ODBC Driver 13 for SQL Server})
    * `:hostname` - The server hostname (default: localhost)
    * `:database` - The name of the database (default: MSSQL_DB environment variable)
    * `:username` - Username (default: MSSQL_UID environment variable)
    * `:password` - User password (default: MSSQL_PWD environment variable)

  `Mssqlex` uses the `DBConnection` framework and supports all `DBConnection`
  options like `:idle`, `:after_connect` etc.
  See `DBConnection.start_link/2` for more information.

  ## Examples

      iex> {:ok, pid} = Mssqlex.start_link(database: "mr_microsoft")
      {:ok, #PID<0.70.0>}
  """
  @spec start_link(Keyword.t) :: {:ok, pid}
  def start_link(opts) do

    opts = opts
    |> Keyword.put_new(:odbc_driver, "{ODBC Driver 13 for SQL Server}")
    |> Keyword.put_new(:hostname, "localhost")
    |> Keyword.put_new(:database, System.get_env("MSSQL_DB"))
    |> Keyword.put_new(:username, System.get_env("MSSQL_UID"))
    |> Keyword.put_new(:password, System.get_env("<PASSWORD>"))

    DBConnection.start_link(Mssqlex.Protocol, opts)
  end

  def query(conn, statement, params, opts \\ []) do
    DBConnection.prepare_execute(conn, %Query{name: "", statement: statement}, params, opts)
  end
end<commit_msg>adding spec and documentation to thge query function of Mssqlex. paired jae<commit_after>defmodule Mssqlex do
  @moduledoc """
  Documentation for Mssqlex.
  """

  @doc """
  Connect to a MS SQL Server using ODBC.

  ## Options

    * `:odbc_driver` - The driver ODBC will use (default: {ODBC Driver 13 for SQL Server})
    * `:hostname` - The server hostname (default: localhost)
    * `:database` - The name of the database (default: MSSQL_DB environment variable)
    * `:username` - Username (default: MSSQL_UID environment variable)
    * `:password` - User password (default: MSSQL_PWD environment variable)

  `Mssqlex` uses the `DBConnection` framework and supports all `DBConnection`
  options like `:idle`, `:after_connect` etc.
  See `DBConnection.start_link/2` for more information.

  ## Examples

      iex> {:ok, pid} = Mssqlex.start_link(database: "mr_microsoft")
      {:ok, #PID<0.70.0>}
  """

  alias Mssqlex.Query

  @spec start_link(Keyword.t) :: {:ok, pid}
  def start_link(opts) do

    opts = opts
    |> Keyword.put_new(:odbc_driver, "{ODBC Driver 13 for SQL Server}")
    |> Keyword.put_new(:hostname, "localhost")
    |> Keyword.put_new(:database, System.get_env("MSSQL_DB"))
    |> Keyword.put_new(:username, System.get_env("MSSQL_UID"))
    |> Keyword.put_new(:password, System.<PASSWORD>_<PASSWORD>("<PASSWORD>"))

    DBConnection.start_link(Mssqlex.Protocol, opts)
  end

  @doc """
  Executes a query against an MS SQL Server with ODBC.

  Statement and params should be in the format required by the Erlang ODBC application.

  For examples see [Using the Erlang API guide](http://www1.erlang.org/doc/apps/odbc/getting_started.html#param_query).
  """
  @spec query(pid(), binary(), [{:odbc.odbc_data_type(), [any()]}], Keyword.t) ::
    {:ok, binary(), Mssqlex.Result.t}
  def query(conn, statement, params, opts \\ []) do
    DBConnection.prepare_execute(conn, %Query{name: "", statement: statement}, params, opts)
  end
end
{'fraction_non_alphanumeric': 0.13792102206736354, 'fraction_numerical': 0.005516840882694541, 'mean_word_length': 4.096153846153846, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1014286', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1138, 'n_words': 310}