sqlitestudio icon indicating copy to clipboard operation
sqlitestudio copied to clipboard

Creating view malforms database

Open mohmad-null opened this issue 1 year ago • 0 comments
trafficstars

3.4.4, 3.3.3, even 2.1.5

Create a database:

CREATE TABLE urls (
	url_id			INTEGER		PRIMARY KEY		AUTOINCREMENT,
	url				TEXT	 	UNIQUE						NOT NULL
);

CREATE TABLE lookups (
	lookup_id		  	INTEGER  	PRIMARY KEY AUTOINCREMENT,
	url_id			 	INTEGER 	REFERENCES urls (url_id) ON DELETE CASCADE		NOT NULL,
	content_hash	   	TEXT	 	COLLATE NOCASE,
	retrieval_datetime 	DATETIME	DEFAULT (datetime('now'))
);

CREATE VIEW v_most_recent_lookup_per_url AS
	SELECT url_id,
		   MAX(retrieval_datetime) AS retrieval_datetime
	  FROM lookups
	 GROUP BY url_id;
	 

All runs fine.

Now run this, replacing "db2" with whatever the schema alias is:

CREATE VIEW db2.v_latest_content_hash_for_url AS
	SELECT
		url,
		content_hash
	FROM
		db2.lookups l
	JOIN
		(SELECT
			*
		FROM
			db2.v_most_recent_lookup_per_url
		) sub
		ON l.url_id = sub.url_id and l.retrieval_datetime = sub.url_id
	JOIN
		db2.urls USING (url_id)

SQLite studio will now drop the entire database and be unable to re-open it, as it's now "malformed".

The problem is the schema part of CREATE VIEW [schema].v_latest_content_hash_for_url - if you leave it empty SQLite will refuse to run it. If you add a schema, it'll break.

The same create-view query runs just fine via Python, but then SQLiteStudio can't open the file ("malformed").

mohmad-null avatar May 05 '24 09:05 mohmad-null

have the same question

shwnyao avatar Aug 21 '22 12:08 shwnyao

This repo pops up when searching for websocket pushing strategies. It seems that subclassing app.callback is a bit heavier than subclassing Output.

shouldsee avatar Sep 30 '22 08:09 shouldsee

Just wanted to update as a user not as a developer. I use this in my project, something i inherited. The new dash components are not compatible with the dash-devices. I don't remember off-hand which dash version is compatible with this project, but its the older dash version. (I think for my purpose, the latest stable dash is dash==1.19.0). I am in process of working around dash-devices to switch to newer dash compatibility.

sambidwasti avatar Jan 12 '23 20:01 sambidwasti