testing – How can I set up an a SQLite memory database to improve PHPUnit test speeds?

I’m trying to speed up a functional Drupal test.
Given a test…

...
  public function the_front_page_loads_for_anonymous_users() {
    $this->config('system.site')
      ->set('page.front', '/node')
      ->save(TRUE);

    $this->drupalGet('<front>');

    $assert = $this->assertSession();
    $assert->pageTextContains('Welcome to Drupal');
    $assert->pageTextContains('No front page content has been created yet.');
  }

This test runs really slow against my database … 2+ mins.

If I use a test sqlite database, it drops to around 1.6 mins
<env name="SIMPLETEST_DB" value="sqlite://localhost/logs/test.sqlite"/>

If I use a in-memory database, <env name="SIMPLETEST_DB" value="sqlite://localhost/:memory:"/>, Drupal detects no database and runs install.php

How can I set up an sqlite memory database to improve test speeds?

testing – Druapl, PHPunut and Sqlite

I’m trying to speed up a functional Drupal test.
Given a test…

...
  public function the_front_page_loads_for_anonymous_users() {
    $this->config('system.site')
      ->set('page.front', '/node')
      ->save(TRUE);

    $this->drupalGet('<front>');

    $assert = $this->assertSession();
    $assert->pageTextContains('Welcome to Drupal');
    $assert->pageTextContains('No front page content has been created yet.');
  }

This test runs really slow against my database … 2+ mins.

If I use a test sqlite database, it drops to around 1.6 mins
<env name="SIMPLETEST_DB" value="sqlite://localhost/logs/test.sqlite"/>

If I use a in-memory database, <env name="SIMPLETEST_DB" value="sqlite://localhost/:memory:"/>, Drupal detects no database and runs install.php

How can I set up an sqlite memory database to improve test speeds?

Return all rows in sqlite query (Swift)?

i have this function to get all rows from one table call “coords”, i want to return this rows to use them in another func, but in the moment to print in my other func just show me the last row, this is my code:

func getCoords() -> (hour1:String,getLat1:Double,getLon1:Double, conCorrds1:Int) {

    let queryStatementString = "SELECT * FROM coords;"

    var queryStatement: OpaquePointer?
      if sqlite3_prepare_v2(db,queryStatementString,-1,&queryStatement,nil) == SQLITE_OK {
        while (sqlite3_step(queryStatement) == SQLITE_ROW) {
          //let id = sqlite3_column_int(queryStatement, 0)
           hour1 = String(cString: sqlite3_column_text(queryStatement, 1))
           getLat = sqlite3_column_double(queryStatement, 2)
           getLon = sqlite3_column_double(queryStatement, 3)
           conCorrds = Int(sqlite3_column_int(queryStatement, 4))
          //print("Query Result COORDS:")
          //print("|(hour1!) | (getLat!) | (getLon!) |(conCorrds!)")
        }
      } else {
          let errorMessage = String(cString: sqlite3_errmsg(db))
          print("nQuery is not prepared (errorMessage)")
      }
      sqlite3_finalize(queryStatement)
     
    return (hour1,getLat,getLon,conCorrds)
}

And in my another function:

let coordsInfo = getCoords()
print(coordsInfo)

in the console:
(hour1: “10:00:16”, getLat1: 19.4354778, getLon1: -99.1364789, conCorrds1: 3)

can anybody help me?

android – SQLite – get every row that has a common entry in the second column

I am working on a Android studios project and i have a table that has two columns item and listname.

enter image description here

i want to get all the items that have a commun Listname so in this case if i were looking for items that have Market as a Listname i only want to get the last 4 from the table, i only want to return the items. i have this but it keeps crashing.

   public Cursor getItem(String listname) {
    SQLiteDatabase db = this.getWritableDatabase();

    String selectQuery = "SELECT  * FROM " + LIST_ITEM_TABLE + " WHERE "
            + ItemListName + " = " + listname;

    Cursor c = db.rawQuery(selectQuery, null);
    
    return c;
}

sql server – How should I shift values to one place back in SqLite?

I have a SqLite DB in which i have 16 columns as id, and f1 to f15.

Now Mistakenly I entered data from 2 column, leaving the first one empty. Now my all values are one place ahead i.e value of last column of first row is in 1st column of 2nd row.

Now I wish to correct this so that all values at their right place . Any query for this problem?

Error al insertar con sqlite en asynctask Android

Les comento mi problema aunque después añadiré código (ahora estoy desde el móvil).

Estoy realizando un gestor de archivos en android por lo que al iniciar la app se lanza un asynctask que realiza una actualización de la base de datos con los archivos nuevos que hay en disco, es decir, obtiene una lista de los archivos y carpetas almacenados en disco y hace insert/update de cada archivo.

Hasta ahí todo bien, el problema es que cuando en el hilo principal el usuario trata de listar los archivos y carpetas abre un cursor, este cursor finaliza cuando obtengo el listado.

Mientras que el cursor está abierto la asynctask sigue haciendo inserts/updates por lo que me lanza:

Attempt to reopen an already-closed object: sqlitedatabase

Mi pregunta es la siguiente:
¿Cómo podría parar la ejecución del asynctask o bien parar los inserts/updates cuando se abra un cursor?

Muchas gracias de antemano.
Tengo que editar para poner código.

query – PostGreSQL vs SQLite

I was wondering because recently I installed PostGreSQL, and I have previously installed DB Browser for SQLite on my Windows 10 computer. If it PostGreSQL has a DB Browser GUI for the tables, because I was using it and I was using SQL Query language to create a table, and insert values into the table. I thought this question would be on topic for the site, if its not please let me know.

mysql – How to use SELECT statement to get data from SQlite table using with dictionary values?

I have below dictionary values.
Example:

required = {'ID1': ('Name1', 'Name2'),
            'ID2': ('Name1', 'Name3'),
            'ID3': ('Name2')}

I want to print address of every matched names in above format.

Example Output:

('ID1', 'adress1' ,'adress2'),
('ID2', 'adress1' ,'adress3'),
('ID3', 'adress2')

Below is my example code.

import sqlite3


conn=sqlite3.connect('emp.db')
conn.execute("""CREATE TABLE IF NOT EXISTS branch
        (Emp_ID TEXT UNIQUE,
    Emp_Name    TEXT UNIQUE,
    Emp_Address TEXT
    )""")

conn.execute("""INSERT OR IGNORE INTO branch(Emp_ID, Emp_Name, Emp_Address) 
    VALUES('Emp1', 'Name1', 'adress1')""")

conn.execute("""INSERT OR IGNORE INTO branch(Emp_ID, Emp_Name, Emp_Address) 
    VALUES('Emp2', 'Name2', 'adress2')""")

conn.execute("""INSERT OR IGNORE INTO branch(Emp_ID, Emp_Name, Emp_Address) 
    VALUES('Emp3', 'Name3', 'adress3')""")

conn.execute("""INSERT OR IGNORE INTO branch(Emp_ID, Emp_Name, Emp_Address) 
    VALUES('Emp4', 'Name4', 'adress4')""")

conn.execute("""INSERT OR IGNORE INTO branch(Emp_ID, Emp_Name, Emp_Address) 
    VALUES('Emp5', 'Name5', 'adress5')""")

conn.commit()
conn.close()

For example ‘ID1’ (column) should not to be changed.
And ‘name1’ should take its address and ‘name2’should take its address and all matched names should take their addresses. Which statements are useful for my scenario. Is it possible? If possible how to to?