From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id MJxVED0u1WMwGgAAbAwnHQ (envelope-from ) for ; Sat, 28 Jan 2023 15:16:29 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id sHRsDz0u1WPWEQAAG6o9tA (envelope-from ) for ; Sat, 28 Jan 2023 15:16:29 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E06B93E9ED for ; Sat, 28 Jan 2023 15:16:28 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLlzm-0005Xc-E9; Sat, 28 Jan 2023 09:15:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pLlzk-0005X0-3C for emacs-orgmode@gnu.org; Sat, 28 Jan 2023 09:15:52 -0500 Received: from mail.bundesbrandschatzamt.de ([198.7.63.95]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pLlzi-000222-HD for emacs-orgmode@gnu.org; Sat, 28 Jan 2023 09:15:51 -0500 Received-SPF: pass (mail.bundesbrandschatzamt.de: authenticated connection) receiver=mail.bundesbrandschatzamt.de; client-ip=91.64.203.22; helo=smtpclient.apple; envelope-from=baron@bundesbrandschatzamt.de; x-software=spfmilter 2.001 http://www.acme.com/software/spfmilter/ with libspf2-1.2.10; Received: from smtpclient.apple (ip5b40cb16.dynamic.kabel-deutschland.de [91.64.203.22]) (authenticated bits=0) by mail.bundesbrandschatzamt.de (8.14.7/8.14.7) with ESMTP id 30SEFlN7023285 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sat, 28 Jan 2023 14:15:48 GMT From: Andreas Gerler Content-Type: multipart/signed; boundary="Apple-Mail=_C2A31D98-940B-4CD7-8BFF-07209388A36A"; protocol="application/pgp-signature"; micalg=pgp-sha512 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: ob-sql dbconnection engine Date: Sat, 28 Jan 2023 15:15:40 +0100 References: <31A92865-F761-42B4-BDD6-C8189CDE2045@bundesbrandschatzamt.de> <871qng86fa.fsf@localhost> To: emacs-orgmode@gnu.org In-Reply-To: Message-Id: <2FAAE35F-03C9-4933-B48E-97326801D476@bundesbrandschatzamt.de> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (mail.bundesbrandschatzamt.de [198.7.63.95]); Sat, 28 Jan 2023 14:15:48 +0000 (UTC) X-DCC--Metrics: heimdall.bundesbrandschatzamt.de 1102; Body=1 Fuz1=1 Fuz2=1 X-SMTP-Vilter-Version: 1.3.6 X-Spamd-Symbols: PGP_BLOCK,SPF_PASS,UNPARSEABLE_RELAY Received-SPF: permerror client-ip=198.7.63.95; envelope-from=baron@bundesbrandschatzamt.de; helo=mail.bundesbrandschatzamt.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1674915389; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=4JBxbaWQ7GYHVLDWBkWj1hbYCAxrPsvwfN06m/2TW58=; b=Mos/iM3iwkbnxgSZ/kzVTyWA3QJ+CnbY0kDkvytPGpORxwfcv7fSkaBZRcxlpL4kEGQUc9 YLIPaYm/lZHIJhwmGhXY/LgJr6Y+u0nthZKVeNBci2M1s7Eyjnbbe+8NbGFnVs/o4G9wT+ //4bmaTlBRE0FXM0ffxaS41HEchXfhr7stW5MvGm31KARk1lzcSrjHMsOIk8sr0mL6vwkG 7cE02DMqMy2aONWjqBSDYaDXk0/ZaWpMmuAqMt3l8eu76etkaH4bH3perQicCS93A8smVP 2jMINx8uGkPLqT4cilECH5Uye/ukRkEn8n5wTzVErvtQkcYIeTnHn2tUJsDSVA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1674915389; a=rsa-sha256; cv=none; b=SMY14BMRSoI/e4hPvWprqw0i0Y9zRBh69R+R8lgusWhPsfZ7Xgt533sZwG8V9ueQdRi7O/ aK9YLShnpJNx8PJJK+J0+kgpS9lU5fqfx8VlA6cILH58Zwtgva5RFAAndg+3UD2BEKezSH AyHqxTDyHCYttaN0ab2NwXSje2Jp7A1X9/bCbIGnOUH0oqFeU2gYMySaM6eORZ0E4LMuXb nStTJtedh4jicKCIPYGITq1Rsg9eeuHhpUJ+WydAF+bNgKXrqtveo5Mk9NHQt9R0XpA1ti Soix50RrzwHzg0VKHohavyNIOt5gGQ2jULzfY4ylwAd6j/ilKdyyqtZI5Y5iwQ== X-Spam-Score: -2.97 X-Migadu-Spam-Score: -2.97 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: E06B93E9ED X-Migadu-Scanner: scn1.migadu.com X-TUID: VUs4wuVTnaxP --Apple-Mail=_C2A31D98-940B-4CD7-8BFF-07209388A36A Content-Type: multipart/mixed; boundary="Apple-Mail=_76C660C6-60F4-4AF8-BBAD-A356F568F855" --Apple-Mail=_76C660C6-60F4-4AF8-BBAD-A356F568F855 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Hi! and a new patch with proper commit message. --Apple-Mail=_76C660C6-60F4-4AF8-BBAD-A356F568F855 Content-Disposition: attachment; filename=0002-lisp-ob-sql.el-sql-connection-alist-engine.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0002-lisp-ob-sql.el-sql-connection-alist-engine.patch" Content-Transfer-Encoding: quoted-printable =46rom=2098c5f83ae289252610be8ce80452fad97f6433c7=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Andreas=20Gerler=20= =0ADate:=20Sat,=2028=20Jan=202023=20= 14:49:02=20+0100=0ASubject:=20[PATCH=202/2]=20lisp/ob-sql.el:=20= sql-connection-alist=20engine=0A=0A*=20ob-sql.el=20= (org-babel-find-db-connection-param):=20with=20dbconnection=20use=0A= sql-product=20for=20engine=20parameter.=0A=0ASigned-off-by:=20Andreas=20= Gerler=20=0A---=0A=20lisp/ob-sql.el=20|=20= 12=20++++++++----=0A=201=20file=20changed,=208=20insertions(+),=204=20= deletions(-)=0A=0Adiff=20--git=20a/lisp/ob-sql.el=20b/lisp/ob-sql.el=0A= index=20f73e7003f..c6a192ae3=20100644=0A---=20a/lisp/ob-sql.el=0A+++=20= b/lisp/ob-sql.el=0A@@=20-231,10=20+231,14=20@@=20database=20= connections."=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(:dbuser=20.=20sql-user)=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(:dbpassword=20.=20sql-password)=0A=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(:dbinstance=20.=20sql-dbinstance)=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(:database=20.=20sql-database)))=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (:database=20.=20sql-database)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(:engine=20= .=20sql-product)))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(mapped-name=20(cdr=20(assq=20name=20name-mapping))))=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20(cadr=20(assq=20mapped-name=0A-=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(cdr=20= (assoc-string=20dbconnection=20sql-connection-alist=20t))))))))=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20(if=20(string-equal=20":engine"=20name)=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(symbol-name=20(cadr=20= (cadr=20(assq=20mapped-name=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(cdr=20= (assoc-string=20dbconnection=20sql-connection-alist=20t))))))=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(cadr=20(assq=20mapped-name=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (cdr=20(assoc-string=20dbconnection=20sql-connection-alist=20t)))))))))=0A= =20=0A=20(defun=20org-babel-execute:sql=20(body=20params)=0A=20=20=20= "Execute=20a=20block=20of=20Sql=20code=20with=20Babel.=0A@@=20-247,7=20= +251,7=20@@=20This=20function=20is=20called=20by=20= `org-babel-execute-src-block'."=0A=20=20=20=20=20=20=20=20=20=20= (dbpassword=20(org-babel-find-db-connection-param=20params=20= :dbpassword))=0A=20=20=20=20=20=20=20=20=20=20(dbinstance=20= (org-babel-find-db-connection-param=20params=20:dbinstance))=0A=20=20=20=20= =20=20=20=20=20=20(database=20(org-babel-find-db-connection-param=20= params=20:database))=0A-=20=20=20=20=20=20=20=20=20(engine=20(cdr=20= (assq=20:engine=20params)))=0A+=20=20=20=20=20=20=20=20=20(engine=20=20= (org-babel-find-db-connection-param=20params=20:engine))=0A=20=20=20=20=20= =20=20=20=20=20(colnames-p=20(not=20(equal=20"no"=20(cdr=20(assq=20= :colnames=20params)))))=0A=20=20=20=20=20=20=20=20=20=20(in-file=20= (org-babel-temp-file=20"sql-in-"))=0A=20=20=20=20=20=20=20=20=20=20= (out-file=20(or=20(cdr=20(assq=20:out-file=20params))=0A--=20=0A2.39.0=0A= =0A= --Apple-Mail=_76C660C6-60F4-4AF8-BBAD-A356F568F855 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 28. Jan 2023, at 13:57, Andreas Gerler = wrote: >=20 > Hi! >=20 > without the patch your org source block has to look like: >=20 > #+begin_src sql :engine mysql :dbconnection mysqldb1 > SELECT * FROM nodes; > #+end_src >=20 > with that patch you can just type >=20 > #+begin_src sql :dbconnection mysqldb1 > SELECT * FROM nodes; > #+end_src >=20 > because your engine is mapped to sql-product in your = sql-connection-alist: >=20 > (setq sql-connection-alist > '((mysqldb1 (sql-product 'mysql) > (sql-server "10.10.42.1") > (sql-user "dbadmin") > (sql-password "foo") > (sql-database "testdb")))) >=20 >=20 >> On 27. Jan 2023, at 14:15, Ihor Radchenko = wrote: >>=20 >> Andreas Gerler writes: >>=20 >>> as I am still learning more elisp it took me some try and error but = I can use the sql-product now within dbconnection. >>> Using :engine still works as well. >>> Still wondering if there is a more elegant way for the if clause. >>=20 >> Thanks for the patch! >> Could you please explain in more details what the patch does? >>=20 >> -- >> Ihor Radchenko // yantar92, >> Org mode contributor, >> Learn more about Org mode at . >> Support Org development at , >> or support my work at >>=20 >=20 >=20 >=20 > so long=E2=80=A6 >=20 > Andreas Gerler >=20 > =E2=80=94 >=20 > http://www.bundesbrandschatzamt.de/~baron --Apple-Mail=_76C660C6-60F4-4AF8-BBAD-A356F568F855-- --Apple-Mail=_C2A31D98-940B-4CD7-8BFF-07209388A36A Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIzBAEBCgAdFiEERvQn3i5iUQoCDew4lRrK1qSO/JEFAmPVLgwACgkQlRrK1qSO /JHjEhAAkUDqGAjrgwE6IoUhZe3blznCfUXV/bZtvHm+gUuh+FL+93y1hZds1vOl KgdtL374cFcQ8zxUi6OSMrqcCuSlNt9koQaTQwCmLGzKXGhbsu5VtiI6s6HgsF2h N+1KEiEPGy0MkzmIvTx+j8737lJA0HrN3zl01lvx7iyyalyCquM0B3UuizINpHUn 9W0GcSA8BWEjOQpr9qrPAgP217SE1QIpw5nfDBjJlXmyPN1/VPYwJqbFtXvHHL0b z/mydNrsrgTnNVJqsCJcb57U01MUmSZ/lrZs2q09P4bHP4nUDcjNGlRdGQcjwMj0 sjRL1W2m8FhYJ0lt6AQBswgVrzMWZpkCBco9XF3m4OCqWZggif+1tQAbkzV6ilev kad379a6misERlfa+aLlrPUYRDWWoMnrByNN30b6MwfufqJdH+WucMLSm3I96/Q3 mmvQ6c782ptBytgkCDYsjfScA/oIoUfY50KZIMp8SVZ1lEEyF8OACpI+6s/pOZTj Jd21hmXTUK9tZ/wXbI7IE2OLN8YPhhiVZzhOIT1KvU4HWRSbTHPPcQZ0sw8E9R5c 26plk8E8BAZbc6PlalJwCZwqbxT3QSwQySVOnrARFG9sSAai2t2ZwJmyFVPHH78a X64I89jeXxfH3IZGxH6I5yUI8vqY2BCNQ15yuJbWcJVYweJN/Iw= =taMQ -----END PGP SIGNATURE----- --Apple-Mail=_C2A31D98-940B-4CD7-8BFF-07209388A36A--