Changeset: 5bf09dc95278 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5bf09dc95278
Modified Files:
        clients/python2/monetdb/control.py
        clients/python2/monetdb/sql/connections.py
        clients/python3/monetdb/control.py
        clients/python3/monetdb/sql/connections.py
Branch: default
Log Message:

fixed path to socket. accept host and user args.


diffs (96 lines):

diff --git a/clients/python2/monetdb/control.py 
b/clients/python2/monetdb/control.py
--- a/clients/python2/monetdb/control.py
+++ b/clients/python2/monetdb/control.py
@@ -62,8 +62,12 @@ class Control:
     Use this module to manage your MonetDB databases. You can create, start,
     stop, lock, unlock, destroy your databases and request status information.
     """
-    def __init__(self, hostname=None, port=None, passphrase=None,
-                 unix_socket="/tmp/.s.merovingian.50000"):
+    def __init__(self, hostname=None, port=50000, passphrase=None,
+                 unix_socket=None):
+
+        if not unix_socket:
+            unix_socket = "/tmp/.s.merovingian.%i" % port
+
         self.server = mapi.Connection()
         self.hostname = hostname
         self.port = port
diff --git a/clients/python2/monetdb/sql/connections.py 
b/clients/python2/monetdb/sql/connections.py
--- a/clients/python2/monetdb/sql/connections.py
+++ b/clients/python2/monetdb/sql/connections.py
@@ -29,8 +29,8 @@ class Connection(object):
     default_cursor = cursors.Cursor
 
     def __init__(self, database, hostname=None, port=50000, username="monetdb",
-                 password="monetdb", unix_socket="/tmp/.s.monetdb.50000",
-                 autocommit=False):
+                 password="monetdb", unix_socket=None, autocommit=False,
+                 host=None, user=None):
         """ Set up a connection to a MonetDB SQL database.
 
         database    -- name of the database
@@ -43,6 +43,15 @@ class Connection(object):
         autocommit  -- enable/disable auto commit (default: False)
 
         """
+        if not unix_socket:
+            unix_socket = "/tmp/.s.monetdb.%i" % port
+
+        # The DB API spec is not specific about this
+        if host:
+            hostname = host
+        if user:
+            username = user
+
         self.mapi = mapi.Connection()
         self.mapi.connect(hostname=hostname, port=int(port), username=username,
                           password=password, database=database, language="sql",
diff --git a/clients/python3/monetdb/control.py 
b/clients/python3/monetdb/control.py
--- a/clients/python3/monetdb/control.py
+++ b/clients/python3/monetdb/control.py
@@ -62,8 +62,12 @@ class Control:
     Use this module to manage your MonetDB databases. You can create, start,
     stop, lock, unlock, destroy your databases and request status information.
     """
-    def __init__(self, hostname=None, port=None, passphrase=None,
-                 unix_socket="/tmp/.s.merovingian.50000"):
+    def __init__(self, hostname=None, port=50000, passphrase=None,
+                 unix_socket=None):
+
+        if not unix_socket:
+            unix_socket = "/tmp/.s.merovingian.%i" % port
+
         self.server = mapi.Connection()
         self.hostname = hostname
         self.port = port
diff --git a/clients/python3/monetdb/sql/connections.py 
b/clients/python3/monetdb/sql/connections.py
--- a/clients/python3/monetdb/sql/connections.py
+++ b/clients/python3/monetdb/sql/connections.py
@@ -29,8 +29,8 @@ class Connection(object):
     default_cursor = cursors.Cursor
 
     def __init__(self, database, hostname=None, port=50000, username="monetdb",
-                 password="monetdb", unix_socket="/tmp/.s.monetdb.50000",
-                 autocommit=False):
+                 password="monetdb", unix_socket=None, autocommit=False,
+                 host=None, user=None):
         """ Set up a connection to a MonetDB SQL database.
 
         database    -- name of the database
@@ -43,6 +43,15 @@ class Connection(object):
         autocommit  -- enable/disable auto commit (default: False)
 
         """
+        if not unix_socket:
+            unix_socket = "/tmp/.s.monetdb.%i" % port
+
+        # The DB API spec is not specific about this
+        if host:
+            hostname = host
+        if user:
+            username = user
+
         self.mapi = mapi.Connection()
         self.mapi.connect(hostname=hostname, port=int(port), username=username,
                           password=password, database=database, language="sql",
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to