Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cause sqlite to sleep in execution

Tags:

sql

sqlite

sleep

Is there a similar SQL-expression to sleep like MS SQL WAITFOR for sqlite?

Alternatively, is there a way to make a sqlite SQL-query run for a long time without adding a lot of rows to the database?

It's for a test so it needs to be done running a query using the db driver.

like image 988
Asken Avatar asked May 20 '14 07:05

Asken


1 Answers

SQLite has no built-in function for this, but in most languages, it is possible to create a user-defined function:

import sqlite3
import time

con = sqlite3.connect(":memory:")
con.create_function("sleep", 1, time.sleep)
c = con.cursor()
c.execute("SELECT sleep(1.23)")
like image 136
CL. Avatar answered Sep 30 '22 05:09

CL.