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

  • Home
  • SEARCH
  • 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 6139539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:00:11+00:00 2026-05-23T18:00:11+00:00

my perl script is multi threaded and in each thread i have to write

  • 0

my perl script is multi threaded and in each thread i have to write something to a sqlite3 database. But as you might guess, i get a lot of

DBD::SQLite::db do failed: database is locked at script.pl line 264.

messages. I read that sqlite3 is able to handle multi threaded situations, even INSERT statements but i think i expect to much when inserting fro 8 threads at the same time.

ok, so its not possible this way but isn’t there a possibility to perform a check before inserting to see if the database is locked (or busy) and then wait until is free again?

I really don’t want to change to a “real” DBMS cause its only a simple script.

Thank you

  • 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-05-23T18:00:12+00:00Added an answer on May 23, 2026 at 6:00 pm

    If you need to block until you can get to the database, try exclusive transactions, i.e.,

    $dbh->do("begin exclusive transaction") or die $dbh->errstr;
    #inserts here
    $dbh->do("commit transaction") or die $dbh->errstr;
    

    That way, you delegate the locking to SQLite, rather than doing it in Perl. This is safer for all sorts of reasons, not least of which is you might have the database open in something other than Perl, or in another Perl process rather than a thread.

    And, as @mob commented, Perl threading is a somewhat funny beast. I’d just get the locking done by the database, where it belongs.

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

Sidebar

Related Questions

I have perl, v5.6.1 built for MSWin32-x86-multi-thread Binary build 638 provided by ActiveState. I
I have written a Perl script that performs many one-sample t-tests. I get thousands
My perl script is slow but works. I am considering throwing it out and
I have a Perl script that I'm attempting to set up using Perl Threads
I have a Perl script where I maintain a very simple cache using a
I have Perl script and need to determine the full path and filename of
I have this Perl script with many defined constants of configuration files. For example:
I have a little Perl script (On Windows) that checks some files for me
I have the following, simplest Perl CGI script: use strict; use warnings; use CGI();
I have this piece of script : #!/usr/bin/perl use strict; use warnings; use Data::Dumper;

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.