From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: Interacting with PostgreSQL Date: Wed, 25 Nov 2020 07:18:46 +0300 Message-ID: References: <87r1oms1z3.fsf@passepartout.tim-landscheidt.de> <87sg8yuz33.fsf@passepartout.tim-landscheidt.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39901"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0 (3d08634) (2020-11-07) Cc: help-gnu-emacs@gnu.org To: Tim Landscheidt Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 25 05:25:07 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khmMd-000AGZ-4e for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 25 Nov 2020 05:25:07 +0100 Original-Received: from localhost ([::1]:51756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khmMc-0003OT-5s for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 24 Nov 2020 23:25:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khmLy-0003Mj-JT for help-gnu-emacs@gnu.org; Tue, 24 Nov 2020 23:24:27 -0500 Original-Received: from static.rcdrun.com ([95.85.24.50]:36363) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khmLu-0003Wi-1f for help-gnu-emacs@gnu.org; Tue, 24 Nov 2020 23:24:24 -0500 Original-Received: from localhost ([::ffff:41.202.241.56]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by static.rcdrun.com with ESMTPSA id 00000000002C1AE8.000000005FBDDC74.00002AAB; Wed, 25 Nov 2020 04:24:20 +0000 Content-Disposition: inline In-Reply-To: <87sg8yuz33.fsf@passepartout.tim-landscheidt.de> Received-SPF: pass client-ip=95.85.24.50; envelope-from=bugs@gnu.support; helo=static.rcdrun.com 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_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:125550 Archived-At: * Tim Landscheidt [2020-11-25 02:15]: > As a mere mortal :-), when for example I add triggers to > five tables with three test cases (INSERT, UPDATE, DELETE) > each, I will not remember which of the triggers or test > cases have been set/inserted/updated/deleted. Thank you. I am probably not getting it right. I got impression that when I set triggers to work they are set to be forgotten and I do not need to think of it any more. In general I am developing SQL in the SQL file, so anything I do I write first in the file. Rarely I will go to sql-postgres to change some view or similar. Better workflow is always writing it first in the file and then executing chunks from file. It is just fine for testing. Benefit is that I can recreate new database from the file that has much better readability then the SQL dump. > Also, my mind will be focussed on fixing the functions/etc. Worst > case is that I miss that psql has reverted to auto-commit mode and > my not-yet-working trigger/query overwrites good data with garbage. OK, I do not know about that. And I am not using auto commit mode, did not know that it exists and will not switch to it. > So I definitely want to be sure that my changes are (easily) > revertable until they are working properly. Quite understandable. I did not encounter similar problems in last so many years. > I prefer to use shell-quote-argument and other prebaked > functions because "did not break yet" means that there is a > chance that I will discover at 3 AM that my data has been > garbled, and now I would have to find the error in my quote > function, fix all the data that has been trashed, and do all > that under time pressure because I have a deadline at 4 AM. I said "did not break yet" as the function is escaping the quotes, maybe backslashes, and I do not remember now if there is anything else to be escaped really. That function did not break ever is also the case. When it is there you can inspect it and look into specification and then make test cases and see if it works well or not. I am sure that Perl has also somewhere SQL escaping functions and it also has bugs, so there is not much difference. PostgreSQL has also bugs, programmers are not perfect. I have used this function in Perl. sub sql_escape ($) { my ($self, $string) = @_; return unless $string; $string =~ s/'/''/g; $string =~ s/\\/\\\\/g; return $string; } > So if I have a working solution with call-process and DBI > that is partially tested every day by millions of users, I > rather not replace just for the sake of replacing it. Hm, yes and no. Good when you are familiar with it. My side I like to interact with Emacs Lisp directly to be kind of free of Perl. I am interested in your work. What do you store in the database? Do you interact through Emacs with it?