help-gnu-emacs
[Top][All Lists]
Advanced

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

[SQL Mode and MS-SQL and Free TDS]


From: Evan Misshula
Subject: [SQL Mode and MS-SQL and Free TDS]
Date: Thu, 25 Jan 2024 01:41:01 -0500

Hi Mr. Mauger,

Thank you for your work maintaining and improving SQL-Mode. In customizing
it to work for me. I changed several  items and wanted to make those
changes available to the wider community.

1. I used Free-TDS (https://www.freetds.org/). FreeTDS is a set of
libraries for Unix and Linux that allows your programs to natively talk to
Microsoft SQL Server and Sybase databases. My employer uses MS SqlServer.

2. To get this to work, I had to change to functions. The first was to drop
"-D" parameter which has been deprecated by osql.  My version of
sql-comint-ms appears below.

(defun sql-comint-ms (product options &optional buf-name)
  "Create comint buffer and connect to Microsoft SQL Server."
  ;; Put all parameters to the program (if defined) in a list and call
  ;; make-comint.
  (let ((params
         (append
          (if (not (string= "" sql-user))
              (list "-U" sql-user))
;;          (if (not (string= "" sql-database))
;;              (list "-D" sql-database))
          (if (not (string= "" sql-server))
              (list "-S" sql-server))
          options)))
    (setq params
          (if (not (string= "" sql-password))
              `("-P" ,sql-password ,@params)
            (if (string= "" sql-user)
                ;; If neither user nor password is provided, use system
                ;; credentials.
                `("-E" ,@params)
              ;; If -P is passed to ISQL as the last argument without a
              ;; password, it's considered null.
              `(,@params "-P"))))
    (sql-comint product params buf-name)))

osql no longer supports the "-w" parameter and sql-ms-options appears below

(defcustom sql-ms-options '(" " " " " ")
  ;; -w is the linesize
  "List of additional options for `sql-ms-program'."
  :type '(repeat string)
  :version "22.1")

Thank you for your consideration. If you like these changes I can prepare a
pull request to support Free-TDS and another to update ms for changes to
osql.

Best,
Evan Misshula


reply via email to

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