<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Srimathi10</title>
    <description>The latest articles on DEV Community by Srimathi10 (@srimathi10).</description>
    <link>https://dev.to/srimathi10</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2897984%2F08ce734c-11c6-4107-ba65-9c812e653fff.png</url>
      <title>DEV Community: Srimathi10</title>
      <link>https://dev.to/srimathi10</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/srimathi10"/>
    <language>en</language>
    <item>
      <title>Utilize Kubernetes for container orchestration</title>
      <dc:creator>Srimathi10</dc:creator>
      <pubDate>Tue, 25 Feb 2025 18:14:41 +0000</pubDate>
      <link>https://dev.to/srimathi10/utilize-kubernetes-for-container-orchestration-mm1</link>
      <guid>https://dev.to/srimathi10/utilize-kubernetes-for-container-orchestration-mm1</guid>
      <description></description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>containers</category>
    </item>
    <item>
      <title>Create and manage Docker containers for application deployment</title>
      <dc:creator>Srimathi10</dc:creator>
      <pubDate>Tue, 25 Feb 2025 18:14:26 +0000</pubDate>
      <link>https://dev.to/srimathi10/create-and-manage-docker-containers-for-application-deployment-9a2</link>
      <guid>https://dev.to/srimathi10/create-and-manage-docker-containers-for-application-deployment-9a2</guid>
      <description></description>
      <category>docker</category>
      <category>devops</category>
      <category>containers</category>
    </item>
    <item>
      <title>How to Create and Upload a Python Package to PyPi: A Step-by-Step Guide</title>
      <dc:creator>Srimathi10</dc:creator>
      <pubDate>Tue, 25 Feb 2025 15:28:31 +0000</pubDate>
      <link>https://dev.to/srimathi10/how-to-create-and-upload-a-python-package-to-pypi-a-step-by-step-guide-5j9</link>
      <guid>https://dev.to/srimathi10/how-to-create-and-upload-a-python-package-to-pypi-a-step-by-step-guide-5j9</guid>
      <description>&lt;p&gt;Creating and uploading a Python package to PyPi (Python Package Index) is an essential skill for sharing your work with the community. In this blog post, we’ll walk through the complete process using an example package, &lt;strong&gt;file_compressor&lt;/strong&gt;, which compresses files into a &lt;code&gt;.zip&lt;/code&gt; format. By the end of this guide, you’ll be able to create, build, and upload your own Python package to PyPi.&lt;/p&gt;

&lt;p&gt;Let’s get started!&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 1: Setting Up Your Environment&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Before we begin creating the Python package, you need to set up your environment with the necessary tools. If you don't have Python installed, please install it from &lt;a href="https://www.python.org/downloads/" rel="noopener noreferrer"&gt;python.org&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We will also need a few packages to help build and upload the package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;setuptools wheel twine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;What Are These Packages?&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;setuptools&lt;/strong&gt;: A tool for packaging Python projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;wheel&lt;/strong&gt;: A packaging format for Python distribution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;twine&lt;/strong&gt;: A tool to securely upload your package to PyPi.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 2: Create Your Package Directory&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now that you have the necessary tools, create a directory for your project. Inside this directory, you will organize your Python package and related files.&lt;/p&gt;

&lt;p&gt;Here’s how your directory structure might look for the &lt;strong&gt;file_compressor&lt;/strong&gt; package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;file_compressor/
├── file_compressor/              # Package directory containing the Python code
│   └── __init__.py               # Mark this directory as a Python package
├── setup.py                      # Metadata about the package
├── LICENSE                       # License information (MIT, GPL, etc.)
├── README.md                     # Documentation about your package
├── MANIFEST.in                   # Include additional non-Python files (optional)
└── tests/                        # Unit tests for the package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Package Code Example:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In the &lt;code&gt;file_compressor/&lt;/code&gt; directory, you might create a Python file, such as &lt;code&gt;compress.py&lt;/code&gt;, which contains the core functionality of your package, like compressing files into a &lt;code&gt;.zip&lt;/code&gt; format.&lt;/p&gt;

&lt;p&gt;Here’s an example implementation of &lt;code&gt;compress.py&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;zipfile&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;compress_file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;output_file&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Compress a single file into a zip archive.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;zipfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ZipFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;w&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;zipfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ZIP_DEFLATED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;zipf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;zipf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;basename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_file&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;File &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;input_file&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; compressed to &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;output_file&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;Step 3: Create the &lt;code&gt;setup.py&lt;/code&gt; File&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;setup.py&lt;/code&gt; file contains important metadata for your Python package, such as its name, version, and description. Here is an example &lt;code&gt;setup.py&lt;/code&gt; for &lt;strong&gt;file_compressor&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;setuptools&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;find_packages&lt;/span&gt;

&lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;file_compressor&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;              &lt;span class="c1"&gt;# Name of your package
&lt;/span&gt;    &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0.1.0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                     &lt;span class="c1"&gt;# Initial version
&lt;/span&gt;    &lt;span class="n"&gt;packages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;find_packages&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;            &lt;span class="c1"&gt;# Find all Python packages
&lt;/span&gt;    &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;A Python package for compressing files into .zip format&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;long_description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;README.md&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="n"&gt;long_description_content_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;text/markdown&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;author&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Your Name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;author_email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;your-email@example.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://github.com/your-username/file_compressor&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# Link to GitHub repository
&lt;/span&gt;    &lt;span class="n"&gt;classifiers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Programming Language :: Python :: 3&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;License :: OSI Approved :: MIT License&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Operating System :: OS Independent&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;install_requires&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;                 &lt;span class="c1"&gt;# Add any dependencies here (if needed)
&lt;/span&gt;    &lt;span class="n"&gt;python_requires&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;gt;=3.6&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;             &lt;span class="c1"&gt;# Specify the minimum Python version
&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;name&lt;/strong&gt;: The name of your package (e.g., &lt;code&gt;file_compressor&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;version&lt;/strong&gt;: The current version of your package (start with &lt;code&gt;0.1.0&lt;/code&gt; for the first release).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;description&lt;/strong&gt;: A short description of what your package does.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;long_description&lt;/strong&gt;: A detailed description (this can be fetched from your &lt;code&gt;README.md&lt;/code&gt; file).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;author&lt;/strong&gt;: Your name or organization.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;author_email&lt;/strong&gt;: Your email address.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;url&lt;/strong&gt;: The URL to your package's homepage (usually your GitHub repository).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 4: Create a README.md&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;README.md&lt;/code&gt; file is essential to explain the purpose of your package and how to use it. Here's a simple example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# File Compressor&lt;/span&gt;

A Python package that compresses files into &lt;span class="sb"&gt;`.zip`&lt;/span&gt; format.

&lt;span class="gu"&gt;## Installation&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
bash&lt;br&gt;
pip install file-compressor&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
## Usage

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
python&lt;br&gt;
from file_compressor import compress_file&lt;/p&gt;

&lt;p&gt;compress_file('path/to/your/file.txt', 'path/to/output/file.zip')&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;Step 5: Build the Package&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now it’s time to build the package. In your project directory (where &lt;code&gt;setup.py&lt;/code&gt; is located), run the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python setup.py sdist bdist_wheel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates distribution archives, which include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;sdist&lt;/code&gt;&lt;/strong&gt;: The source distribution, a &lt;code&gt;.tar.gz&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;bdist_wheel&lt;/code&gt;&lt;/strong&gt;: The wheel distribution, a &lt;code&gt;.whl&lt;/code&gt; file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These files will be stored in a &lt;code&gt;dist/&lt;/code&gt; directory inside your project folder.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 6: Create a PyPi API Token&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To securely upload your package to PyPi, you need to create an API token. Here’s how:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Log in to PyPi&lt;/strong&gt;: Go to &lt;a href="https://pypi.org/" rel="noopener noreferrer"&gt;https://pypi.org/&lt;/a&gt; and log in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Go to Account Settings&lt;/strong&gt;: Click your username in the top-right corner and select &lt;strong&gt;"Account settings"&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create an API Token&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Scroll down to the &lt;strong&gt;API tokens&lt;/strong&gt; section.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"Add API token"&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Provide a name for the token (e.g., "file_compressor upload").&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"Add token"&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Save the API token&lt;/strong&gt;: Make sure to copy and securely store the token. You’ll only see it once.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frhb7mh3zglspvtkk9jro.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frhb7mh3zglspvtkk9jro.png" alt="Image description" width="800" height="501"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 7: Upload to PyPi&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Once the package is built, you can upload it using &lt;code&gt;twine&lt;/code&gt;. Run the following command to upload the distribution files to PyPi:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;twine upload dist/&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; __token__ &lt;span class="nt"&gt;-p&lt;/span&gt; &amp;lt;your-pypi-api-token&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;&amp;lt;your-pypi-api-token&amp;gt;&lt;/code&gt; with the actual token you generated in the previous step.&lt;/p&gt;

&lt;p&gt;This will securely upload your package to PyPi. If the upload is successful, you'll see a confirmation message.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk5563g308exjqugmtw5a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk5563g308exjqugmtw5a.png" alt="Image description" width="573" height="676"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 8: Verify Your Package on PyPi&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;After uploading, visit &lt;a href="https://pypi.org/project/file-compressor/" rel="noopener noreferrer"&gt;https://pypi.org/project/file-compressor/&lt;/a&gt; to verify that your package is live on PyPi. You should see the version, description, and files listed.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 9: Install and Test Your Package&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To ensure your package is working correctly, try installing it in a new Python environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;file-compressor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once installed, test it in a Python script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;file_compressor&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;compress_file&lt;/span&gt;

&lt;span class="nf"&gt;compress_file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;path/to/your/file.txt&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;path/to/output/file.zip&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the package works as expected, congratulations! Your package is ready for others to use.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 10: Updating Your Package&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In the future, if you make any updates to your package, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Modify your package (e.g., add new features or fix bugs).&lt;/li&gt;
&lt;li&gt;Update the version number in &lt;code&gt;setup.py&lt;/code&gt; (e.g., from &lt;code&gt;0.1.0&lt;/code&gt; to &lt;code&gt;0.2.0&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Repeat the &lt;strong&gt;build&lt;/strong&gt; and &lt;strong&gt;upload&lt;/strong&gt; steps to publish the new version.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this guide, we've gone over the complete process of creating a Python package, specifically the &lt;strong&gt;file_compressor&lt;/strong&gt; package, from scratch. You learned how to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set up the package structure.&lt;/li&gt;
&lt;li&gt;Write the &lt;code&gt;setup.py&lt;/code&gt; and &lt;code&gt;README.md&lt;/code&gt; files.&lt;/li&gt;
&lt;li&gt;Build and upload your package to PyPi.&lt;/li&gt;
&lt;li&gt;Use an API token for secure uploads.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With this knowledge, you can now share your Python packages with the world via PyPi! If you want to explore more about package creation, check out the &lt;a href="https://packaging.python.org/" rel="noopener noreferrer"&gt;official PyPi documentation&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>pip</category>
      <category>package</category>
      <category>compressor</category>
    </item>
    <item>
      <title>Blog: Building a Visitor Management System with PyQt6 and SQLite</title>
      <dc:creator>Srimathi10</dc:creator>
      <pubDate>Tue, 25 Feb 2025 14:09:47 +0000</pubDate>
      <link>https://dev.to/srimathi10/blog-building-a-visitor-management-system-with-pyqt6-and-sqlite-1b27</link>
      <guid>https://dev.to/srimathi10/blog-building-a-visitor-management-system-with-pyqt6-and-sqlite-1b27</guid>
      <description>&lt;p&gt;In this blog, we'll explore how to create a simple yet effective Visitor Management System (VMS) using Python's powerful PyQt6 library and SQLite for database management. This system allows users to register, search, edit, and delete visitor records in a building or organization. Let's break down the key features and explain how everything fits together.&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;What is the Visitor Management System?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;A Visitor Management System (VMS) is designed to efficiently manage the flow of visitors in any facility. It captures details like the visitor's name, the company they represent, and contact information. This system ensures that these records are easily accessible and can be updated when necessary. In this project, we will be building a simple VMS using PyQt6 for the GUI and SQLite as the backend database.&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;Setting Up the Environment&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Before we jump into the code, make sure you have Python installed on your system. You'll also need the following libraries:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;PyQt6&lt;/strong&gt; – This will be used for the graphical user interface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SQLite&lt;/strong&gt; – For storing visitor data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can install the necessary libraries using &lt;code&gt;pip&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;pyqt6 sqlite3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  &lt;strong&gt;Database Design&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;At the heart of our VMS is the SQLite database. The system interacts with a database to store, retrieve, and modify visitor records. The &lt;code&gt;visitors&lt;/code&gt; table will consist of the following fields:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;id&lt;/code&gt; – An auto-incremented primary key.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;name&lt;/code&gt; – Name of the visitor.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;company&lt;/code&gt; – The company the visitor is associated with.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;contact&lt;/code&gt; – Contact information for the visitor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's the SQL script to create the &lt;code&gt;visitors&lt;/code&gt; table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="n"&gt;visitors&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="nb"&gt;INTEGER&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="n"&gt;AUTOINCREMENT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;company&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;contact&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures that if the table doesn't already exist, it will be created. The database connection is managed via the &lt;code&gt;DatabaseConnection&lt;/code&gt; class in the code.&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;The PyQt6 User Interface&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The user interface (UI) for this VMS is built using PyQt6. We create the main window and add functionality for adding, searching, editing, and deleting visitor records.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Menu Bar&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;The menu bar provides easy access to common operations. It includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;File Menu&lt;/strong&gt;: This contains the action to add a new visitor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Help Menu&lt;/strong&gt;: Displays an "About" dialog.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edit Menu&lt;/strong&gt;: Contains actions like searching for visitors.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Table View&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;A table view (&lt;code&gt;QTableWidget&lt;/code&gt;) is used to display the visitor records. The columns are set to show:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Id&lt;/strong&gt;: The visitor's ID.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visitor Name&lt;/strong&gt;: Name of the visitor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Company&lt;/strong&gt;: The company the visitor is associated with.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contact&lt;/strong&gt;: Contact details.&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;Key Features and Dialogs&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The system is designed with several dialogs to handle various operations like adding, editing, deleting, and searching for visitors.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add Visitor Dialog (&lt;code&gt;InsertDialog&lt;/code&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This dialog allows the user to input visitor details (name, company, and contact) and add them to the database.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Edit Visitor Dialog (&lt;code&gt;EditDialog&lt;/code&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The user can update the details of an existing visitor by selecting a record from the table and modifying the information.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Delete Visitor Dialog (&lt;code&gt;DeleteDialog&lt;/code&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This dialog prompts the user to confirm before deleting a visitor's record from the database.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Search Visitor Dialog (&lt;code&gt;SearchDialog&lt;/code&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users can search for a visitor by name. If found, the matching record is highlighted in the table.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;Connecting Everything Together&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Here's how the components interact:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Database Connection&lt;/strong&gt;: The &lt;code&gt;DatabaseConnection&lt;/code&gt; class manages the connection to the SQLite database. It provides methods to connect to the database and execute queries like creating the table, inserting, updating, and deleting records.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;MainWindow Class&lt;/strong&gt;: This is the heart of the UI. It contains a table (&lt;code&gt;QTableWidget&lt;/code&gt;) to display records, a toolbar with actions like "Add Visitor" and "Search", and a status bar that shows options to edit or delete records when a table cell is clicked.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dialogs&lt;/strong&gt;: Each dialog handles a specific user action (insert, update, delete, search). When the user interacts with the main window, these dialogs allow for smooth data entry and modification.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;Code Breakdown&lt;/strong&gt;
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Creating the Table&lt;/strong&gt;: The first step is ensuring that the &lt;code&gt;visitors&lt;/code&gt; table is created when the application starts. This is handled by the &lt;code&gt;DatabaseConnection&lt;/code&gt; class, which includes the &lt;code&gt;create_table&lt;/code&gt; method.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DatabaseConnection&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;database_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;visitor_db.db&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;database_file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;database_file&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;connection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;database_file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;connection&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create_table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;connection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;cursor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
        CREATE TABLE IF NOT EXISTS visitors (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            name TEXT NOT NULL,
            company TEXT NOT NULL,
            contact TEXT NOT NULL
        );
        &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Adding a Visitor&lt;/strong&gt;: The &lt;code&gt;InsertDialog&lt;/code&gt; class allows users to input visitor information and store it in the SQLite database.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;InsertDialog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;QDialog&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setWindowTitle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Insert Visitor Data&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setFixedWidth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setFixedHeight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;layout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QVBoxLayout&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="c1"&gt;# Add visitor name widget
&lt;/span&gt;        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;visitor_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QLineEdit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;visitor_name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setPlaceholderText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Visitor Name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addWidget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;visitor_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# Add company name widget
&lt;/span&gt;        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;company_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QLineEdit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;company_name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setPlaceholderText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Company Name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addWidget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;company_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# Add contact number widget
&lt;/span&gt;        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contact_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QLineEdit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contact_number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setPlaceholderText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Contact Number&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addWidget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contact_number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# Add a submit button
&lt;/span&gt;        &lt;span class="n"&gt;button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;QPushButton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Register Visitor&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clicked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_visitor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addWidget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setLayout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add_visitor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;visitor_name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;company&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;company_name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;contact&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contact_number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;connection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;DatabaseConnection&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;cursor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;INSERT INTO visitors (name, company, contact) VALUES (?, ?, ?)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                       &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;company&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;contact&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;main_window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load_data&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The Visitor Management System created with PyQt6 and SQLite offers a simple yet functional solution to managing visitor data. The system features an intuitive graphical interface, with a database backend to persist visitor records. Users can easily add, search, edit, and delete records, making this system suitable for many real-world applications.&lt;/p&gt;

&lt;p&gt;Check out the complete source code and contribute to the project on &lt;a href="https://github.com/Srimathi10/visitor_management" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Feel free to customize and extend this application based on your needs. &lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>sqllite</category>
      <category>database</category>
    </item>
    <item>
      <title>Blog Post: Merging PDF Files Using Python</title>
      <dc:creator>Srimathi10</dc:creator>
      <pubDate>Tue, 25 Feb 2025 12:48:22 +0000</pubDate>
      <link>https://dev.to/srimathi10/blog-post-merging-pdf-files-using-python-3n5j</link>
      <guid>https://dev.to/srimathi10/blog-post-merging-pdf-files-using-python-3n5j</guid>
      <description>&lt;p&gt;In this tutorial, we'll walk through a Python script that merges multiple PDF files into one. This functionality is helpful in various scenarios, such as combining reports, invoices, or documents into a single file. To achieve this, we'll use the popular Python library PyPDF2, which allows for easy manipulation of PDF files.&lt;/p&gt;

&lt;p&gt;If you're interested in the source code for this project, you can find it on GitHub: &lt;a href="https://github.com/Srimathi10/Merge_pdf" rel="noopener noreferrer"&gt;Merge_pdf GitHub Repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Step 1: Install the Required Library&lt;br&gt;
To begin, you need to install the PyPDF2 library. This library simplifies tasks like merging, splitting, and rotating PDF pages. Open your Command Prompt or Terminal and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install PyPDF2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will install the necessary dependency for the script. If you see any warning related to the pip version, it's a good idea to update it, although it is not strictly required for the script to work.&lt;/p&gt;

&lt;p&gt;Step 2: Writing the Code&lt;br&gt;
Now let's dive into the code that merges the PDF files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import PyPDF2
import glob
from pathlib import Path

# Create a list of PDF filepaths
filepaths = glob.glob("files/*.pdf")

# Create a PDF merger object
pdf_merger = PyPDF2.PdfMerger()

# Go through each PDF file and append to the merger object
for filepath in filepaths:
    # Append the current PDF file to the merger
    pdf_merger.append(filepath)

# Output the merged PDF
with open("merged.pdf", "wb") as output_pdf:
    pdf_merger.write(output_pdf)

print("PDFs merged successfully into 'merged.pdf'")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation of the Code:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Import Libraries:&lt;/p&gt;

&lt;p&gt;PyPDF2: This library is used to manipulate PDF files in Python.&lt;br&gt;
glob: It helps in searching for PDF files in a specified folder.&lt;br&gt;
Path: From the pathlib module, this provides an easy way to handle file paths.&lt;/p&gt;

&lt;p&gt;Gather PDF File Paths:&lt;/p&gt;

&lt;p&gt;glob.glob("files/*.pdf") finds all PDF files in the files/ directory and stores their paths in the filepaths list.&lt;/p&gt;

&lt;p&gt;Merge PDFs:&lt;/p&gt;

&lt;p&gt;A PyPDF2.PdfMerger() object is created to merge the PDFs.&lt;br&gt;
For each file in the filepaths list, the append() method is used to add the PDF to the merger.&lt;/p&gt;

&lt;p&gt;Output the Merged PDF:&lt;/p&gt;

&lt;p&gt;The merged PDF is written to a new file called merged.pdf using the pdf_merger.write(output_pdf) function.&lt;/p&gt;

&lt;p&gt;Run the Script:&lt;/p&gt;

&lt;p&gt;After running the script, you will see the message PDFs merged successfully into 'merged.pdf'.&lt;/p&gt;

&lt;p&gt;Step 3: Running the Script&lt;br&gt;
Once the script is ready, you can execute it from your Command Prompt or Terminal with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python main.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the script runs successfully, you will see the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\projects\merge_pdf&amp;gt;python main.py
PDFs merged successfully into 'merged.pdf'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conclusion:&lt;br&gt;
By following this tutorial, you should now be able to merge multiple PDF files into a single PDF document using Python and PyPDF2. This approach is ideal for combining reports, documents, or invoices with minimal code. The script is simple yet effective for working with multiple PDFs, and you can easily adapt it for other PDF manipulation tasks.&lt;/p&gt;

&lt;p&gt;The source code for this project is available on GitHub: &lt;a href="https://github.com/Srimathi10/Merge_pdf" rel="noopener noreferrer"&gt;Merge_pdf GitHub Repository&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;Feel free to modify the script for tasks like splitting PDFs, rotating pages, or extracting text. The possibilities are endless!&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>python</category>
      <category>pdf</category>
    </item>
  </channel>
</rss>
