1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved [SQLite3] Asynchronous queries

Discussion in 'Development' started by Muqsit, May 23, 2017.

  1. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Is there any way to execute queries (SQLite3) in an asynchronous task? This is what I have tried:
    PHP:
    class that extends AsyncTask{

        private 
    $dbpath;
        private 
    $query;

        public function 
    __construct(string $query){
            
    $this->dbpath Main::getDatabasePath(); //returns "plugins/Test/Test.db"
            
    $this->query $query;
        }

        public function 
    onRun(){
            
    $sql = new SQLite3($this->dbpath);
            
    $sql->exec($this->query);
            
    //^ERROR -> SQLite3::exec(): The SQLite3 object has not been correctly initialised
        
    }
    }
    EDIT: Solved. The database was being closed in one of the class's __destruct(). My bad. That should work^ flawlessly.
     
    Last edited: May 23, 2017
    jasonwynn10 and Legoboy0215 like this.
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    I'm wondering if I should make a variant of libasynql for SQLite3 too
     
    jasonwynn10, Levi and Muqsit like this.
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    please!
     
    jasonwynn10 likes this.
  4. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    Sorry for bumb, but is this solved or no?
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    https://www.sqlite.org/wal.html
    Though that may help you, do remember SQLite3 is a flat file database, not a server. SQLite3 locks the database so no other processes can use it simultaneously. But I think you can pipeline the queries.
     
  6. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    what are differences in SQLITE and SQLITE3?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.