skip to navigation
skip to content

Not Logged In

MySQLObject 1.0

A Python class to convert a simple object in a MySQL connection driver.

Latest Version: 1.3.1

MySQL Object

A Python class to convert a simple object in a MySQL connection driver.

**Latest version: 1.0**

It provides a set of functions to interact with a MySQL server directly
from a class. These functions are designed in a natural way that allows
an user to forget about implementation details.

How to use it

It is pretty simple to instance it:

    from mysqlobject import mysqlobject

    class myclass (mysqlobject):
        def __init__(self):
            super(myclass, self).__init__()
            self.mysqlobject_params["host"] = "localhost",
            self.mysqlobject_params["port"] = 3306,
            self.mysqlobject_params["user"] = "root",
            self.mysqlobject_params["passwd"] = "$ecre7",
            self.mysqlobject_params["db"] = "test",
            self.mysqlobject_params["use_unicode"] = True,
            self.mysqlobject_params["charset"] = "utf8",
            self.mysqlobject_params["compress"] = False,
            self.mysqlobject_params["cursor"] = "DictCursor",

It is also easy to use it:

        all = myclass.mysql_select("SELECT VERSION();")
        one = myclass.mysql_select_one("SELECT VERSION();")
        lastid = myclass.mysql_insert(
            "INSERT INTO test (name) VALUES ('test');"
        affected = myclass.mysql_update("UPDATE test SET name = 'test2';")
        deleted = myclass.mysql_delete("DELETE FROM test;")
    except Exception, e
        print e

You can also execute many queries:

    query = "INSERT INTO test (name) VALUES ('%s');"
    data = ['test', 'test2']
    affected = mysql_query_many(query, data)

What functions do I have?

### mysql\_select

It returns all the rows from the query.

### mysql\_select\_one

It returns one row from the given query.

### mysql\_insert

It returns the last inserted ID from your insertion query.

### mysql\_update

It returns the number of affected rows.

### mysql\_delete

It returns the number of deleted rows.

The source can be browsed at ""

Contact me
For any requests, please contact me at:
File Type Py Version Uploaded on Size
MySQLObject-1.0.tar.gz (md5) Source 2012-06-25 3KB
  • Downloads (All Versions):
  • 16 downloads in the last day
  • 75 downloads in the last week
  • 467 downloads in the last month