<?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 Bruno Moraes on Medium]]></title>
        <description><![CDATA[Stories by Bruno Moraes on Medium]]></description>
        <link>https://medium.com/@brunobva?source=rss-dc9a0e0b80d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SJO0llcuu86-3c9wNK0h4w@2x.jpeg</url>
            <title>Stories by Bruno Moraes on Medium</title>
            <link>https://medium.com/@brunobva?source=rss-dc9a0e0b80d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 21:46:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@brunobva/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[SQL Store Procedure]]></title>
            <link>https://medium.com/@brunobva/sql-store-procedure-d8bfe9a705d6?source=rss-dc9a0e0b80d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8bfe9a705d6</guid>
            <category><![CDATA[owasp]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[appsec]]></category>
            <dc:creator><![CDATA[Bruno Moraes]]></dc:creator>
            <pubDate>Fri, 28 Jun 2024 07:31:05 GMT</pubDate>
            <atom:updated>2024-07-02T08:11:34.313Z</atom:updated>
            <content:encoded><![CDATA[<p>So, I choose to talk about that, because it is something that I always see at security talks or people from AppSec discussing regarding the OWASP top vulnerabilities (click <a href="https://info.veracode.com/owasp-top-10-infographic-resource.html">here</a> and <a href="https://owasp.org/www-project-top-ten/">here</a>) and I never stop to see and study regarding those vulnerabilities.</p><p>So, as I am trying to study Python and Javascript, to improve my development skills and Devops either, I will start to shared some material to study regarding these topics.</p><p>As I said, please, feel free to comment. I really want to dive in and learn with those blog posts.</p><p>For this example, we will use SQL, Python and Javascript.</p><p>First, let’s create a stored procedure in SQL:</p><ol><li><em>SQL Stored Procedure</em></li></ol><p>Consider a database table users:</p><pre>CREATE TABLE users (<br>    id INT PRIMARY KEY AUTO_INCREMENT,<br>    username VARCHAR(50),<br>    email VARCHAR(50)<br>);</pre><p>Here’s a stored procedure to insert a new user into the users table:</p><pre>DELIMITER $$<br><br>CREATE PROCEDURE AddUser(IN p_username VARCHAR(50), IN p_email VARCHAR(50))<br>BEGIN<br>    INSERT INTO users (username, email) VALUES (p_username, p_email);<br>END$$<br><br>DELIMITER ;</pre><p>This stored procedure AddUser takes two parameters, p_username and p_email, and inserts them into the users table</p><h3><strong>2. Using Python to Call the Stored Procedure</strong></h3><p>Let’s see how to call this stored procedure using Python’s mysql-connector-python library.</p><pre>import mysql.connector<br><br>def add_user(username, email):<br>    # Establish the database connection<br>    conn = mysql.connector.connect(<br>        host=&#39;localhost&#39;,<br>        user=&#39;root&#39;,<br>        password=&#39;your_password&#39;,<br>        database=&#39;your_database&#39;<br>    )<br>    cursor = conn.cursor()<br>    <br>    try:<br>        # Call the stored procedure<br>        cursor.callproc(&#39;AddUser&#39;, [username, email])<br>        conn.commit()<br>        print(&quot;User added successfully!&quot;)<br>    except mysql.connector.Error as err:<br>        print(f&quot;Error: {err}&quot;)<br>    finally:<br>        cursor.close()<br>        conn.close()<br><br># Example usage<br>add_user(&#39;john_doe&#39;, &#39;john.doe@example.com&#39;)</pre><p>In this example, callproc is used to call the stored procedure AddUser with parameters.</p><h3>3. Using JavaScript to Call the Stored Procedure</h3><p>Now, let’s call the same stored procedure using JavaScript with the mysql package.</p><pre>const mysql = require(&#39;mysql&#39;);<br><br>const connection = mysql.createConnection({<br>    host: &#39;localhost&#39;,<br>    user: &#39;root&#39;,<br>    password: &#39;your_password&#39;,<br>    database: &#39;your_database&#39;<br>});<br><br>connection.connect();<br><br>function addUser(username, email) {<br>    const query = &#39;CALL AddUser(?, ?)&#39;;<br>    <br>    connection.query(query, [username, email], (error, results) =&gt; {<br>        if (error) {<br>            console.error(&#39;Error:&#39;, error);<br>        } else {<br>            console.log(&#39;User added successfully!&#39;);<br>        }<br>    });<br>}<br><br>// Example usage<br>addUser(&#39;jane_doe&#39;, &#39;jane.doe@example.com&#39;);<br><br>connection.end();</pre><p>In this example, `<strong>connection.query</strong>` is used to call the stored procedure `<strong>AddUser</strong>` with parameters.</p><h3>4. Exercises to Study</h3><p>Here are some exercises to practice using stored procedures with parameterized queries.</p><h4>Exercise 1: Create a Stored Procedure to Update a User’s Email</h4><ol><li>Create a stored procedure UpdateUserEmail that takes two parameters: p_id (user ID) and p_email (new email).</li><li>Write Python code to call this stored procedure.</li><li>Write JavaScript code to call this stored procedure.</li></ol><h4>Exercise 2: Create a Stored Procedure to Delete a User</h4><ol><li>Create a stored procedure DeleteUser that takes one parameter: p_id (user ID).</li><li>Write Python code to call this stored procedure.</li><li>Write JavaScript code to call this stored procedure.</li></ol><p>These exercises and examples should help you understand how to use parameterized queries and stored procedures with Python and JavaScript.</p><p><strong>Note:</strong> I really want that you enjoy this post. And if you want that I post the solution either or maybe create a git repo to organize that and let the code there. I still think how to “manage” those things.</p><h3><strong>Lets learn!</strong></h3><p>links used:<br><a href="https://owasp.org/www-project-top-ten/">https://owasp.org/www-project-top-ten/</a></p><p><a href="https://info.veracode.com/owasp-top-10-infographic-resource.html">https://info.veracode.com/owasp-top-10-infographic-resource.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8bfe9a705d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[First text/test using medium]]></title>
            <link>https://medium.com/@brunobva/first-text-test-using-medium-d88c168bab38?source=rss-dc9a0e0b80d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d88c168bab38</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Bruno Moraes]]></dc:creator>
            <pubDate>Fri, 28 Jun 2024 06:53:20 GMT</pubDate>
            <atom:updated>2024-06-28T06:53:20.253Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello,</p><p>I will start to write some content regarding some studies that I am doing.<br>My main objective is always share the things that I am learning to help someone who needs and want “dive in” this subject or learn it either.</p><p>I will use english to improve that too. So please, you are free to comment and help me to improve it. Not just for the English, but for the technology that I will write.</p><p>I hope that you enjoy this “blog” and fell free to contact me, to improve the network and learn more and more.</p><p>I am Bruno, work with IT since 2007, I am a IT enthusiastic, love to learn and search how to solve things by different ways.</p><p>Lets go!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d88c168bab38" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>