Deprecated: Creation of dynamic property Timber\Site::$pingback is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Site.php on line 180

Deprecated: Creation of dynamic property Timber\User::$name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/User.php on line 118

Deprecated: Creation of dynamic property Timber\Post::$old_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_thumbnail_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$ext-thumbnail_url is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_metadesc is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_date_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$ping_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_password is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$to_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$pinged is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_content_filtered is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$guid is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$menu_order is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_mime_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_count is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$filter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71
PRQL, un linguaggio moderno per superare le difficoltà di SQL

PRQL, un linguaggio moderno per superare le difficoltà di SQL

Cos'è PRQL, un linguaggio moderno che permette di scrivere e gestire query SQL efficaci.
PRQL, un linguaggio moderno per superare le difficoltà di SQL

Chiunque si occupi di programmazione deve conoscere SQL (Structured Query Language), un linguaggio che permette di interagire con i database relazionali alterandone la struttura (schema), aggiungendo, modificando o gestendo i dati, effettuando interrogazioni con la possibilità di creare e gestire strumenti di controllo e accesso alle informazioni.

PRQL è un moderno linguaggio che si presenta come un sostituto semplice, potente e pipelined di SQL. Come SQL anche PRQL è facilmente leggibile, usa comandi espliciti ed è dichiarativo. Diversamente da SQL, PRQL permette di formare una catena o pipeline di trasformazioni supportando anche caratteristiche astratte come variabili e funzioni.

Un semplice esempio del funzionamento di PRQL mette in evidenza le sue potenzialità: predisponendo una query SQL, anche non particolarmente complessa, spesso ci si accorge dell’inserimento di ripetizioni non necessarie (alcune elaborazioni vengono ripetute nonostante provengano da un’operazione svolta in precedenza).
Clausole SQL come WHERE e HAVING sono sostanzialmente simili ma l’assenza di una priorità fa sì che debbano essere utilizzate in modo distinto.
Singoli operatori SQL, inoltre, possono avere più funzioni e una sintassi piuttosto scomoda porta alla comparsa di errori anche limitandosi a commentare una parte della query.

Nel caso di PRQL, invece, le variabili permettono ad esempio di ridurre le ripetizioni non necessarie rendendo la query molto più leggibile: essa scorre dall’alto verso il basso e ogni singola riga rappresenta una trasformazione del risultato ottenuto alla riga precedente.

PRQL aiuta insomma a “togliere le castagne dal fuoco” soprattutto quando si dovessero sviluppare interrogazioni articolate. Il bello è che può essere utilizzato con qualunque database che accetta query SQL: come passaggio finale, infatti, PRQL traduce automaticamente il lavoro del programmatore in SQL.

In SQL l’aggiunta di un filtro a una query preesistente comporta l’analisi della query stessa per trovare e quindi modificare la clausola WHERE corretta. Con PRQL le successive modifiche sono invece effettuabili a colpo d’occhio, senza alcuno sforzo.

Il nostro suggerimento è quello di provare subito PRQL grazie all’applicazione Web Playground: nel riquadro di sinistra si vede il codice PRQL, a destra la corrispondente trasposizione in SQL. Non male, vero?

PRQL si trova ancora in fase embrionale ma già da ora permette di esplorare e inventarsi moltissimi campi applicativi. Gli sviluppatori del progetto hanno già messo a disposizione un paio di integrazioni, entrambe descritte nelle FAQ. È comunque molto facile aggiungere il supporto PRQL alle proprie app usando i binding per Rust, Python e JavaScript.

Ti consigliamo anche

Link copiato negli appunti