<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vikash Acharya on Medium]]></title>
        <description><![CDATA[Stories by Vikash Acharya on Medium]]></description>
        <link>https://medium.com/@acharya.vikash?source=rss-7ee3ded870dc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Jr-K9DUlYM_zj98O.jpg</url>
            <title>Stories by Vikash Acharya on Medium</title>
            <link>https://medium.com/@acharya.vikash?source=rss-7ee3ded870dc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 23:20:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@acharya.vikash/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating multiple databases on a single RDS]]></title>
            <link>https://medium.com/@acharya.vikash/creating-multiple-databases-on-a-single-rds-a57a3853c890?source=rss-7ee3ded870dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/a57a3853c890</guid>
            <dc:creator><![CDATA[Vikash Acharya]]></dc:creator>
            <pubDate>Sat, 13 May 2023 18:15:40 GMT</pubDate>
            <atom:updated>2023-05-13T18:30:24.187Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Creating multiple databases on a single RDS</strong></p><p>The decision of whether to use multiple databases within a single RDS instance will depend on your specific use case and requirements.</p><p>There could be some reasons why you might want to use multiple databases within a single RDS instance:</p><ol><li><strong><em>Cost Savings</em></strong><em>: By running multiple databases within a single instance, you can save money by consolidating your resources.</em></li><li><strong><em>Simplified Management</em></strong><em>: Managing multiple databases within a single instance is often simpler than managing multiple instances. You can more easily monitor and manage all of your databases from a single location.</em></li><li><strong><em>Improved Performance</em></strong><em>: If your databases have similar resource requirements, running them within a single instance can help you optimize performance. By balancing resource usage across databases, you can ensure that each database has enough resources to perform well.</em></li><li><strong><em>Reduced Latency</em></strong><em>: If your databases need to communicate with one another, running them within a single instance can reduce the latency of those communications. This can improve overall performance and reduce the likelihood of errors or failures.</em></li></ol><p>When we create multiple databases within a single RDS instance, each database will have its own set of tables, stored procedures, and other database objects. These databases are logically separated and can be accessed and managed independently of each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2w0WBjo5jP8J76X8U-CRKQ.png" /></figure><p><strong>Creating multiple databses in single RDS :</strong></p><ol><li>Create database by connecting to RDS host .</li></ol><pre>CREATE DATABASE &lt;database_name&gt;;</pre><p>2. Create users to acces the databse in RDS.</p><pre>CREATE USER &lt;new_user&gt; WITH PASSWORD &#39;&lt;password&gt;&#39;;</pre><p>3. Grant privileges to the new user on the new database. Only those user can access the databse on which they have access rights.</p><pre>GRANT ALL PRIVILEGES ON DATABASE &lt;database_name&gt; TO &lt;new_user&gt;;</pre><p>4. Now you can connect to database by newly created user.</p><p>By following the steps mentioned above you can create multiple databases and its different users to access different databses in a single RDS.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a57a3853c890" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Avoid using shell=true in python subprocess module]]></title>
            <link>https://medium.com/@acharya.vikash/avoid-using-shell-true-in-python-subprocess-module-e95fed487f19?source=rss-7ee3ded870dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/e95fed487f19</guid>
            <dc:creator><![CDATA[Vikash Acharya]]></dc:creator>
            <pubDate>Wed, 06 Oct 2021 05:44:55 GMT</pubDate>
            <atom:updated>2021-10-06T05:44:55.129Z</atom:updated>
            <content:encoded><![CDATA[<p>Using python subprocess module we can execute shell command.<br>This modules takes some arguments along with an option to set ‘shell=true’</p><p>Now the question comes is it safe or recommended to use ‘shell=true’ in subprocess module call which is being use for executing a command.</p><p>The use of shell=true is <strong>strongly discouraged </strong>in cases where the command string is constructed from external input. We should avoid using ‘shell=true’ in subprocess call to avoid <a href="https://en.wikipedia.org/wiki/Shell_injection#Shell_injection">shell injection</a> vulnerabilities.</p><p>Let’s understand it through some examples :</p><pre><strong>def</strong> call_method(command_to_be_executed):<br>    output<strong> = </strong> subprocess.check_output(command_to_be_executed, shell=<strong>True</strong>)</pre><p>In this call you have to pass a string as a command to the shell.</p><p>If call_method is user controlled then it can be used to execute any arbitrary command which can affect system. For example what if command like “rm -rf /” pass to this method as command to execute.</p><p>We can set shell=false and reconstruct our method call by passing a list of strings as command rather than passing a complete string to subprcess.</p><pre>String command = &quot;sudo cat /dirPath/filename&quot;</pre><pre>Convert it to - command_to_be_executed = [&#39;sudo&#39;, &#39;cat&#39;, &#39;/dirPath/filename&#39;]<strong><br>def</strong> call_method(command_to_be_executed):<br>    output<strong> = </strong> subprocess.check_output(command_to_be_executed, shell=<strong>False</strong>)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e95fed487f19" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Listing long running active queries in PostgresSQL]]></title>
            <link>https://medium.com/@acharya.vikash/listing-long-running-active-queries-in-postgressql-8e1c1df759bd?source=rss-7ee3ded870dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e1c1df759bd</guid>
            <dc:creator><![CDATA[Vikash Acharya]]></dc:creator>
            <pubDate>Thu, 30 Sep 2021 05:31:03 GMT</pubDate>
            <atom:updated>2021-09-30T05:31:03.244Z</atom:updated>
            <content:encoded><![CDATA[<p>If any applications which uses PostgresSQL as data storage and then we have to monitor what all queries are running and how much time they are taking to execute so that we can improve our applicatons throughput, if some workflow do perform operations directly on database.</p><p>PostgresSQL provides a predefined view : <strong>pg_stat_activity </strong>(which shows information of current active process, for e.g. currect executing queries, its start time , states etc.</p><p>Sample query to list all such queries which is taking longer time to execute than expected time -</p><p>“SELECT<br> pid,<br> now() — pg_stat_activity.query_start AS duration,<br> left(query,&lt;insert_query_text_length&gt;),<br> state<br>FROM pg_stat_activity<br>WHERE (now() — pg_stat_activity.query_start) &gt; interval ‘&lt;insert_time_interval&gt;’<br>AND state != ‘idle’;”</p><p>Please note that we are listing only active queries which execution in process or currently executing but not idle, that’s why we are passing ‘idle’ in state in pg_stat_activity view. Based on the nature of query and application we can provide the time interval so that above query list only those queries which are taking longer that that defined time.</p><p>Also in above query we can provide the text length of query so it will display only that count of character of query. For e.g. if you provide 75, than it will list first 75 chars of query. If you don’t provide query length it will list full query.</p><p>Once we identify and list all such query , then we can monitor it and take appropriate action like if we need to improve query, need to kill this process etc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e1c1df759bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>