From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] ob-sql.el: Support sqlcmd and cygwin environment Date: Sat, 11 Jun 2016 00:06:24 +0200 Message-ID: <87r3c4em1r.fsf@saiph.selenimh> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBUZU-0003LX-Tt for Emacs-orgmode@gnu.org; Fri, 10 Jun 2016 18:06:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBUZT-0002uu-Fo for Emacs-orgmode@gnu.org; Fri, 10 Jun 2016 18:06:32 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:53823) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBUZT-0002tX-9S for Emacs-orgmode@gnu.org; Fri, 10 Jun 2016 18:06:31 -0400 In-Reply-To: (Xi Shen's message of "Wed, 08 Jun 2016 10:24:44 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Xi Shen Cc: "Emacs-orgmode@gnu.org" Hello, Xi Shen writes: > I would like to apply this path to add sqlcmd support, and allow org-mode > to execute and capture sqlcmd output in cygwin environment. Thank you for the patch. > I added a "platform-convert-file-name" function to convert a *nix path to > Windows path. Should I put this function in ob-sql.el, or somewhere > else? I'm surprised it doesn't exist. Wouldn't `convert-standard-filename' do the job? In any case, it doesn't have a proper prefix. > Subject: [PATCH] ob-sql.el: Support sqlcmd and cygwin environment > > * lisp/ob-sql.el (org-babel-sql-dbstring-mssql): Format Microsoft > sqlcmd command line args. > > * lisp/ob-sql.el (platform-convert-file-name): Convert a *nix path to > Windows long path in Cygwin environment, or do nothing. > > * lisp/ob-sql.el (org-babel-execute:sql): Add `mssql` command support. > For both `msosql` and `mssql` the `input` and `output` path will be > mapped by `platform-convert-file-name` You can write it like * lisp/ob-sql.el (org-babel-sql-dbstring-mssql): Format Microsoft sqlcmd command line args. (platform-convert-file-name): Convert a *nix path to Windows long path in Cygwin environment, or do nothing. (org-babel-execute:sql): Add `mssql' command support. For both `msosql' and `mssql` the `input` and `output' path will be mapped by `platform-convert-file-name' > The `osql` command line tool was last updated in 2004, > https://technet.microsoft.com/en-us/library/aa214012(v=sql.80).aspx, > and could not output the query result in a way that morden > `org-table.el` expects. The `sqlcmd` is the preferred command line > tool to connect the Microsoft SQL Server and it also has a Linux > version, > https://msdn.microsoft.com/en-us/library/hh568447(v=sql.110).aspx. Would it make sense to remove the msosql support then? > +(defun org-babel-sql-dbstring-mssql (host user password database) > + "Make Microsoft sqlcmd commmand line args for database > +connection." The first sentence has to fit on a single line. > + (mapconcat 'identity Nit-pick: #'identity > + "In Cygwin environment convert the file path into Windows long > +path and quote it." > + (if (fboundp 'cygwin-convert-file-name-to-windows) > + (format "\"%s\"" (cygwin-convert-file-name-to-windows file)) > + file)) See above. Regards, -- Nicolas Goaziou