How to Run the Excel Uploader App on Your System

This blog will guide you through setting up and running the Excel Uploader App on your system. This application allows you to upload CSV or Excel files to a MySQL database seamlessly. Follow the steps below to get started!


Prerequisites

Before running the app, ensure the following are installed and configured on your system:

  1. Python (3.7 or later)
    Download and install Python from python.org.
  2. MySQL Server
    Install MySQL on your system. You can download it from mysql.com. Make sure you create a database to test this app.
  3. Pip
    Pip is usually included with Python. Verify installation by running:

    pip --version
    1. Virtual Environment (Optional but Recommended)
      Use a virtual environment to avoid dependency conflicts.

    Step 1: Clone or Copy the Project

    1. Create a directory for the app:
      mkdir excel_uploader
      cd excel_uploader
      

      Save the following files in the excel_uploader directory:

      • app.py: The main application script.
      • templates/index.html: The database connection page.
      • templates/upload.html: The file upload page.

      Ensure the folder structure matches:

      excel_uploader/
      ├── app.py
      └── templates/
          ├── index.html
          └── upload.html
      

      Step 2: Install Dependencies

      1. Create a virtual environment (optional):
        python -m venv venv
        source venv/bin/activate  # Linux/Mac
        venv\Scripts\activate     # Windows
        

       2.Install the required Python libraries:

      pip install flask pandas mysql-connector-python numpy
      

      Step 3: Configure MySQL Database

      1. Open your MySQL client and create a database
        CREATE DATABASE excel_uploader;
        
        1. Note down your host, username, password, and database name. You’ll use these to connect the app to the database.

        Step 4: Run the Application

        1. Run the app:
          python app.py
          
          1. Open your browser and navigate to http://127.0.0.1:5000/.

          Step 5: Connect to the Database

          1. On the MySQL Database Connection page, enter the following:
            • Host: Your MySQL server host (e.g., localhost).
            • Username: Your MySQL username.
            • Password: Your MySQL password.
            • Database: The name of the database you created.
          2. Click Connect. If the connection is successful, you’ll be redirected to the upload page.

          Step 6: Upload Files to the Database

          1. On the File Upload page:
            • Enter a table name where you want the data stored.
            • Select a file (CSV, XLSX, or XLS).
          2. Click Upload. The app will:
            • Validate the file type.
            • Create a table in the database with columns matching the file.
            • Insert the file’s data into the table.
          3. You’ll see a success message indicating the number of records uploaded.

          Step 7: Customize the App (Optional)

          • Change the Secret Key
            Update the app.secret_key in app.py to a secure value.
          • Update the Upload Folder
            Currently, files are uploaded to a temporary directory. To change this, update:

            UPLOAD_FOLDER = 'path_to_your_folder'
            

            Troubleshooting

            • MySQL Connection Error
              Ensure your MySQL server is running and credentials are correct.
            • File Upload Issues
              Check the file format (CSV, XLSX, or XLS) and ensure it’s valid.
            • Dependencies Missing
              If dependencies fail to install, verify that pip is up-to-date:

              pip install --upgrade pip
              

              Conclusion

              You’ve successfully set up and run the Excel Uploader App! This app simplifies uploading data from Excel or CSV files to a MySQL database. Feel free to enhance its functionality or integrate additional features like user authentication or advanced file validations.

Leave a Reply

Shopping cart

0
image/svg+xml

No products in the cart.

Continue Shopping