Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Dec 2004 14:10:40 +0200
From:      Sergey Smitienko <hunter@comsys.com.ua>
To:        ports@freebsd.org
Subject:   /usr/ports/databases/py-MySQL
Message-ID:  <41CFFBC0.5070309@comsys.com.ua>

next in thread | raw e-mail | index | archive | help
Make py-MySQL compile and work with mysql-4-client libraries installed.
btw, I'm not sure, but I guess py-MySQL must be linked against
libmysqlclient_r.so.12 (not included in the patch).

ldd /usr/local/lib/python2.2/site-packages/MySQLmodule.so:
         libmysqlclient.so.12 => 
/usr/local/lib/mysql/libmysqlclient.so.12 (0x4811d000)


--- work/MySQLmodule-1.4/MySQLmodule.c  Mon Dec 27 15:05:56 2004
+++ MySQLmodule.c       Mon Dec 27 15:04:12 2004
@@ -512,7 +512,8 @@
      DBH->dbh_use_result = 0;
      DBH->handle = &DBH->connection;
      DBH->sth = NULL;
-    if (!(mysql_connect(DBH->handle, dbhost, dbuser, dbpass))) {
+    mysql_init(DBH->handle);
+    if (!(mysql_real_connect(DBH->handle, dbhost, dbuser, dbpass, NULL, 
0, NULL, 0l))) {
          if (mysql_error(DBH->handle)[0] != 0) {
             PyErr_SetString(MySQLError,mysql_error(DBH->handle));
         } else {
@@ -735,12 +736,20 @@
       PyObject *args;
  {
      char *dbname;
-
+    char query[512];
+    int rc;
      if (!PyArg_ParseTuple(args, "s:create", &dbname)) return NULL;
      if (self->sth && clear_channel(self->sth)) return NULL;
      Py_XDECREF(self->sth);
      self->sth = NULL;
-    if (mysql_create_db(self->handle, dbname)) {
+
+    rc = snprintf(query, sizeof(query), "CREATE DATABASE %s", dbname);
+    if (rc > sizeof(query)-1) {
+       PyErr_SetString(MySQLError,"Database name too long");
+       return NULL;
+    }
+
+    if (mysql_query(self->handle, query)) {
          PyErr_SetString(MySQLError, mysql_error(self->handle));
          return NULL;
      }
@@ -867,12 +876,21 @@
       PyObject *args;
  {
      char *dbname;
+    char query[512];
+    int rc;

      if (!PyArg_ParseTuple(args, "s:drop", &dbname)) return NULL;
      if (self->sth && clear_channel(self->sth)) return NULL;
      Py_XDECREF(self->sth);
      self->sth = NULL;
-    if (mysql_drop_db(self->handle, dbname)) {
+
+    rc = snprintf(query, sizeof(query), "DROP DATABASE %s", dbname);
+    if (rc > sizeof(query)-1) {
+           PyErr_SetString(MySQLError,"Database name too long");
+           return NULL;
+    }
+
+    if (mysql_query(self->handle, dbname)) {
          PyErr_SetString(MySQLError, mysql_error(self->handle));
          return NULL;
      }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41CFFBC0.5070309>