emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment


From: Nicolas Goaziou
Subject: Re: [O] [PATCH] ob-sql.el: Support sqlcmd and cygwin environment
Date: Sat, 11 Jun 2016 00:06:24 +0200

Hello,

Xi Shen <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]