Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8028599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:11:02+00:00 2026-06-05T00:11:02+00:00

I am working on one project, where I am using mysql database with three

  • 0

I am working on one project, where I am using mysql database with three tables: Requests, Responses, and Users.

The first (index) page is pure HTML where links are available. Those links will execute the Perl script to fetch data from the database and pass the data to a template file, so the next page will be generated.

My question is every time I need to fetch data from the MySQL database, do I need to open a connection with database, and after getting the query result close it again? How can I maintain a connection across queries so there is no need to reconnect to the database?

Can I have each and every query in a single Perl file in seperate functions? If so how to provide the link for Perl function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:11:03+00:00Added an answer on June 5, 2026 at 12:11 am

    Well, this actually seems more like four questions than one. As @DavidO pointed out, under CGI you won’t be maintaining persistent database connections across page requests. However, let me answer the main question you did ask:

    “My question is every time I need to fetch data from the MySQL
    database, do I need to open a connection with database, and after
    getting the query result close it again?”

    If your CGI script needs to run more than one query against the database on a given request, you do not need to close and re-open the connection for each query. Have a look at the DBI docs and you’ll see that you can create one database handle per request, which you can use to run an arbitrary amount of queries against your database as long as the connection remains open.

    Moving forward, I’d encourage you to look at DBIx::Class, which can abstract away much of these details for you. It’s a lot to get your head around if you’re just getting started with Perl and databases, but it’s a real lifesaver once you get comfortable with it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to move project which was using MySQL database to the one
While working a project tonight, I ended up using one .js resource file for
I'm currently working on a project with a one page design that'll slide up
i am using CI 2.1.0 and mysql database for one of my projects. i
I am working on a project using zend framework, php, mysql on ubuntu. I
I am using MySQL and PHP for a project I am working. I have
I'm working on a project where we want to write to a mysql database,
I am working on a project using MySQL and PHP. I will have many
I've been working on a one-person project for a while and I'm using an
I'm working on a project where I am required to query a database using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.