Exemple #1
0
int Connection_init(Connection *self, PyObject *arg)
{
  self->conn = UMConnection_Create (&capi);

  self->rxBufferSize = UMConnection_GetRxBufferSize (self->conn);
  self->txBufferSize = UMConnection_GetTxBufferSize (self->conn);
  self->Error = umysql_Error;
  self->SQLError = umysql_SQLError;

  self->PFN_PyUnicode_Encode = NULL;

  if (PyErr_Occurred())
  {
    PyErr_Format(PyExc_RuntimeError, "Exception is set for no error in %s", __FUNCTION__);
    return -1;
  }

  return 0;
}
Exemple #2
0
result_t mysql::connect(const char *host, int port, const char *username,
                        const char *password, const char *dbName)
{
    if (m_conn)
        return CALL_E_INVALID_CALL;

    m_conn = UMConnection_Create(&capi);
    if (!UMConnection_Connect(m_conn, host, port, username, password, dbName,
                              NULL, MCS_utf8mb4_bin))
    {
        result_t hr = error();

        UMConnection_Destroy(m_conn);
        m_conn = NULL;

        return hr;
    }

    return 0;
}