From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 KLd2BHWMCWPKHwEAbAwnHQ (envelope-from ) for ; Sat, 27 Aug 2022 05:16:05 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id gBRsBHWMCWP2WAAA9RJhRA (envelope-from ) for ; Sat, 27 Aug 2022 05:16:05 +0200 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 CD5FD11E89 for ; Sat, 27 Aug 2022 05:16:03 +0200 (CEST) Received: from localhost ([::1]:41880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRmIk-00041F-9z for larch@yhetil.org; Fri, 26 Aug 2022 23:16:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRmI6-00040x-Qx for emacs-orgmode@gnu.org; Fri, 26 Aug 2022 23:15:24 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:40448) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRmI3-0000fQ-DK for emacs-orgmode@gnu.org; Fri, 26 Aug 2022 23:15:20 -0400 Received: by mail-pj1-x102e.google.com with SMTP id t11-20020a17090a510b00b001fac77e9d1fso9707858pjh.5 for ; Fri, 26 Aug 2022 20:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:from:to:cc; bh=bWdvRbKNsqZv7xWI+sorVi0CHyeyf3pCUFIVa/j9z1Q=; b=oevjg2ObPTuaUsKt9QVMMrbayl93DDRPd3SMIOpf1dg3lNEuZ7kFO8f1geeXRzmyJc SnDynV5pOAnVrDOwNDrbG2UpjRk0g1AifqJG++fd9A66griCYmTWlhoyPxAtLkFIIVNU 8YMC+riIHsOLImyC/ZJgoYaVEsHYDgufXz+VwUsFYubhtv9YcmHqbAHZwzkJakG79p/Z k2VBcV9jyqhJx0cOtb33Yj95CVuOUdh7n7xM/yWxMqNq2xklXclomwJe49v3eGwUayrZ dPptonZiRA7KyivASiSuaVY8BSp9ZGAYWzt4M39OW9sFi+Kh00IWw+jhCgUDjkB80rNN 86cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc; bh=bWdvRbKNsqZv7xWI+sorVi0CHyeyf3pCUFIVa/j9z1Q=; b=1tBB1H5ifgSLPVQV4DqWOoF7cvUClcyvoVnTG2G4vqLoeP0V/+tbrvpiTTsJNzXXPM DkOrkOPj8EOFbQmF6/f3KT9mkZOLOITfgQvk402kI4axI6+vl2zl6YcOZfxYjQhCZlpl +41WUzIfLBQ8IhW8ym8hWbAywTjLXOU771UDWBGxeZJ1S+iOqRluUxzPHIFesb8KKw7j 5yW/+J7yKK2rThElE86CId8ul9pjEJaUgNhi9DdmugTFtKDr2txgi/NvhQNI4vsaPrrt EN8vndJBJBMDOm/yil4UZE+xz9GbWtlbnhCgLW4o4tn7ZC/1azLxOHdkzkx4BVyxwgxI HiXg== X-Gm-Message-State: ACgBeo22zRnMKm1xH0UrPmGZDQvb+1/bomCTXjxGHswEiCrd0QhbHiXJ x7yNyo4jUbwdr9a/modHqu27UdIPr8gVyQ== X-Google-Smtp-Source: AA6agR4H8XFQ7holSdrfdVaqTi8uKDgnuteWpHSuKrDiTLvutMYbMWPeZLIQDg87OhJOeCon+ZrdQQ== X-Received: by 2002:a17:902:e844:b0:16f:9d2:f4ff with SMTP id t4-20020a170902e84400b0016f09d2f4ffmr6471236plg.27.1661570117786; Fri, 26 Aug 2022 20:15:17 -0700 (PDT) Received: from dingbat (2001-44b8-31f2-bb00-842a-7361-87c7-2662.static.ipv6.internode.on.net. [2001:44b8:31f2:bb00:842a:7361:87c7:2662]) by smtp.gmail.com with ESMTPSA id y11-20020a170902d64b00b0017302933b5esm2330799plh.301.2022.08.26.20.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 20:15:17 -0700 (PDT) References: User-agent: mu4e 1.9.0; emacs 29.0.50 From: Tim Cross To: George Moutsopoulos Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] org babel python execute from local buffer to remote session [9.5.4 (9.5.4-ge0b05b @ /home/moutsopoulosg/.emacs.d/elpa/org-9.5.4/)] Date: Sat, 27 Aug 2022 13:05:21 +1000 In-reply-to: Message-ID: <86zgfq5qda.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=theophilusx@gmail.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1661570164; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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:dkim-signature; bh=bWdvRbKNsqZv7xWI+sorVi0CHyeyf3pCUFIVa/j9z1Q=; b=qFoB3afmGQU2ZG63cVGym8Pnj0e+LfpFXILgBM47Qescd4X4iRd/RsQkmc3rRnFaJEWCTn ROx/wAUCzQrVCfzu/9nOwR2PdKOxDQ0D+Azv2A6I55156bKr15jbwXt6kcO3xniayZ4pk8 8sYO86ZAQanxIxx/SbR90WPmeJ+nqrJl2/EXet/rwVJOFTr0nUKmPcbNrZtvKbJIHyNj8x Z/JKb8UPwJ+WOrxpxxpTRNMrV1Y2nYsJZv3rCBS/NhLHU34vL6fy0qfbAdG7ndHoiO510S OVlF+7fvLbweqx+KMdKnpIxwy4od1+Hcex4lrGtiwx340R+xohUSn4YVNnXimg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1661570164; a=rsa-sha256; cv=none; b=uwhM5UurZHRa5fVuUyL6EvWwpKFhsWpZ9jhICnd8z4A674vY/c832mZixI4WVHBWcZMn/h X/79QT9ElM6Rx8hvVWTY7Az18FSA2KEhoZV8VvguOe7qFxUQtkzup3qguKdow7Y5878mJm Zquw2lI8ZC2IcbaxiWv1vG7XquQ1FmhwkDm16PO7MNrTQgmpeRis5cZJAVLp9M4Xm81c0/ 9DDMNLmSMe5SpIpwkN9B49ChDBAR8Ei7yTFmj4p+aP5VN7AAamKfPlu5F2CoIyhzoqkz0w z8nmSOkJ8UZcXsjEdFt8np6gde1QZTfxkQv1mOFzIav2PpgbxNqpZ7jZK1acRA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=oevjg2Ob; dmarc=pass (policy=none) header.from=gmail.com; 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-Spam-Score: -7.31 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=oevjg2Ob; dmarc=pass (policy=none) header.from=gmail.com; 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: CD5FD11E89 X-Spam-Score: -7.31 X-Migadu-Scanner: scn0.migadu.com X-TUID: OCQYK9nc8erZ George Moutsopoulos writes: > Hi all. I often need to run some code on a remote ssh session, because > only there I can access a database and the environment is hard to > replicate, while I want to keep the code I run on my local machine. > > The remote session is initialised with run-python after I change > default-directory and use pythonic-activate. Sending commands from a > local python buffer using python.el works without issues. It would be nice if I can do > the same from a local org-mode buffer from a python source block. > Jujst in case it may be useful, I have found it easiest to use ssh tunnels in this sort of scenario. If you create an ssh tunnel for the port you connect to the database with, you can access the database as if it was running locally. One advantage of this method is that you can use all the normal tools and any language, your not restricted to python. I find this useful as it allows me to use org-mode to manage my database using just sql as well as using other languages (I don't use python, preferring other scripting languages, but same basic principals). I mainly use postgres and with the ssh tunnel approach, I can run the postgres clients locally and have them connect to remote databases which would normally not be possible due to firewalls etc. I've done the same with Oracle and suspect most other dbms would work (as well as other 'services', provided there is a tcp socket). The other advantage is that it avoids the need to modify org mode (or any other tool). You can even use the full power of Emacs' sql mode.