MySQL WebDAV provider


This screenshot shows how the country table of MySQL’s world-db sample database is published as a collection.

All table rows are rendered as non-collections (text files) that contain the CSV formatted columns.

An additional virtual text file _ENTIRE_CONTENTS is created, that contains th whole CSV formatted table content.


The table’s columns are mad accessible as live properties: .. image:: _static/img/DAVExplorer_MySQL.gif


To publish an MySQL database, simply add these lines to the configuration file:

### Publish an MySQL 'world' database as share '/world-db'
from wsgidav.samples.mysql_dav_provider import MySQLBrowserProvider
addShare("world-db", MySQLBrowserProvider("localhost", "root", "test", "world"))

Module description

Implementation of a WebDAV provider that provides a very basic, read-only resource layer emulation of a MySQL database.

This module is specific to the WsgiDAV application. It provides a classes MySQLBrowserProvider.


(see docs/sample_wsgidav.yaml)
MySQLBrowserProvider(host, user, passwd, db)

host - host of database server
user - user_name to access database
passwd - passwd to access database
db - name of database on database server

The MySQLBrowserProvider provides a very basic, read-only resource layer emulation of a MySQL database. It provides the following interface:

  • the root collection shared consists of collections that correspond to table names

  • in each table collection, there is a resource called “_ENTIRE_CONTENTS”. This is a non-collection resource that returns a csv representation of the entire table

  • if the table has a single primary key, each table record will also appear as a non-collection resource in the table collection using the primary key value as its name. This resource returns a csv representation of the record and will also include the record attributes as live properties with attribute name as property name and table name suffixed with colon as the property namespace

This is a very basic interface and below is a by no means thorough summary of its limitations:

  • Really only supports having numbers or strings as primary keys. The code uses a numeric or string comparison that may not hold up if the primary key is a date or some other datatype.

  • There is no handling for cases like BLOBs as primary keys or such. Well, there is no handling for BLOBs in general.

  • When returning contents, it buffers the entire contents! A bad way to return large tables. Ideally you would have a FileMixin that reads the database even as the application reads the file object….

  • It takes too many database queries to return information. Ideally there should be some sort of caching for metadata at least, to avoid unnecessary queries to the database.