Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

magic-removal: Fixed #1481 -- Added support for using alternate MySQL…

… Unix sockets. Thanks, Geert Vanderkelen

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2736 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2f7c4d5ca940a05364a0e67afe5c0d10e7308972 1 parent 08c28d9
Adrian Holovaty authored April 23, 2006
5  django/db/backends/mysql/base.py
@@ -75,9 +75,12 @@ def cursor(self):
75 75
                 'user': settings.DATABASE_USER,
76 76
                 'db': settings.DATABASE_NAME,
77 77
                 'passwd': settings.DATABASE_PASSWORD,
78  
-                'host': settings.DATABASE_HOST,
79 78
                 'conv': django_conversions,
80 79
             }
  80
+            if settings.DATABASE_HOST.startswith('/'):
  81
+                kwargs['unix_socket'] = settings.DATABASE_HOST
  82
+            else:
  83
+                kwargs['host'] = settings.DATABASE_HOST
81 84
             if settings.DATABASE_PORT:
82 85
                 kwargs['port'] = int(settings.DATABASE_PORT)
83 86
             self.connection = Database.connect(**kwargs)
8  docs/settings.txt
@@ -239,6 +239,14 @@ Default: ``''`` (Empty string)
239 239
 Which host to use when connecting to the database. An empty string means
240 240
 localhost. Not used with SQLite.
241 241
 
  242
+If this value starts with a forward slash (``'/'``) and you're using MySQL,
  243
+MySQL will connect via a Unix socket to the specified socket. For example::
  244
+
  245
+    DATABASE_HOST = '/var/run/mysql'
  246
+
  247
+If you're using MySQL and this value *doesn't* start with a forward slash, then
  248
+this value is assumed to be the host.
  249
+
242 250
 DATABASE_NAME
243 251
 -------------
244 252
 

0 notes on commit 2f7c4d5

Please sign in to comment.
Something went wrong with that request. Please try again.