There is a nice answer for the similar question for PostGIS.
I tried to adapt it for my case where I need to connect all points from a point layer, but unfortunately I get duplicate geometries: lines from point n to point m and from point m to point n. Here is the query I use.
check_points is the point layer and
cp_path is the layer where I want to store created lines.
WITH points1 AS (SELECT geometry FROM check_points), points2 AS (SELECT geometry FROM check_points) INSERT INTO cp_path (geometry) SELECT * FROM (SELECT DISTINCT MakeLine(points1.geometry, points2.geometry) FROM points1, points2 WHERE points1.geometry != points2.geometry)
How can I avoid duplicated geometries?