[ENG/ITA] My Most Ambitious Project to Date: Manipulating Huge Amounts of Data from HiveSQL


La versione italiana si trova sotto quella inglese

The italian version is under the english one


My Most Ambitious Project to Date: Manipulating Huge Amounts of Data from HiveSQL

Even though I can't be as consistent as I'd like, my progress with Python is still moving forward, and once I finish a project, I always try to start a new one as soon as possible.

Working on projects with real-world use cases has proven to be not only an enjoyable way to learn but also much more motivating than simply doing exercises for their own sake. Creating something that I or others can actually use is incredibly rewarding—it makes me feel like I'm making progress and doing something useful!

Right now, I'm actually working on not just one, but two projects, although the first one is currently on hold. It's a small website where I've made available the scripts used to collect data for the "Best Author of the Week" and "OdB Engagement Contest" competitions.

The site is already accessible at this link and allows users to quickly find all the aforementioned contests, including the "Unto&Bisunto" contest, as well as access the scripts I've created.



The site is still a "work in progress," but it's already functional and allows @libertycrypto27 and @bencwarmer to collect the data they need without having to download, update, and run my scripts locally (unless they want to for performance reasons).

However, I want to add more features and see if I can improve my mastery of Streamlit to make the site more polished and visually appealing.

As I mentioned earlier, though, this project is temporarily on hold because, while working on it, another idea came to mind, and I just couldn't resist diving into new and intricate lines of code (intricate because I can't make sense of them 🤣).


HiveSQL

At the heart of this second project is HiveSQL, the database created and managed by @arcange, which collects all Hive-related data and makes it accessible quickly, easily, and, for now, for free to everyone.

So it’s worth supporting the related proposal to ensure this service remains free.

My goal is to leverage this massive database to gather an enormous amount of data on Hive users, so I can then manipulate, analyze, categorize, and use it (the data, not the users 😂).

What I plan to do with this data will remain a secret for now because I need to determine if it's feasible and whether it might generate interest. There used to be something similar to what I have in mind, but times change, and just because something worked years ago doesn't mean it will still work today.

In any case, for me, this is primarily a challenge. Working with HiveSQL means learning how to extract data from a database and manipulate it effectively—turning a task that would take months into something that can be completed in just a few seconds.

The toughest challenge, however, is proving to be the first step: correctly extracting the data I need from HiveSQL.

        SQLCommand = f"""  
        SELECT author, body_length, parent_author, depth, LEFT(CONVERT(VARCHAR(MAX), body), 55) AS body  
        FROM dbo.Comments  
        WHERE created > ?   
            AND depth > 0   
            AND parent_author NOT IN ({parent_authors_placeholders})  
            AND author NOT IN ({authors_placeholders});  
        """  

        cursor.execute(SQLCommand, [time] + invalid_parent_authors + invalid_authors)  
        every_comment = cursor.fetchall()  

A query like the one above is still quite difficult for me to fully understand, and for this script I’d say I’m making (ab)use of ChatGPT to an almost excessive extent. I always try to understand the results it provides, but I admit that this time I've relied on it heavily to solve a lot of issues that would have otherwise taken me, at the very least, hours upon hours to figure out.

My hope is that, in the end, some of this sticks in my head so I can continue improving my Python skills and, one day, tackle even more ambitious projects!


cover made with ChatGPT and edited with GIMP

to support the #OliodiBalena community, @balaenoptera is 3% beneficiary of this post


If you've read this far, thank you! If you want to leave an upvote, a reblog, a follow, a comment... well, any sign of life is really much appreciated!


Versione italiana

Italian version


Il Mio Progetto Più Ambizioso Sino ad Oggi: Manipolazione di Enormi Quantità di Dati Provenienti da HiveSQL

Anche se non riesco a metterci tutta la costanza che vorrei, i miei progressi con Python comunque proseguono e, finito un progetto, cerco sempre di far passare meno tempo possibile prima di iniziarne un altro.

Lavorare a progetti con casi d'uso reali si è rivelato infatti non solo un modo piacevole di imparare, ma anche molto più motivante rispetto all'eseguire meri esercizi fini a se stessi: creare qualcosa che io o altri possano usare è estremamente gratificante e mi dà l'impressione di star facendo progressi, oltre che qualcosa di utile!

Attualmente, per la verità, sto lavorando non ad uno, ma a ben due progetti, anche se il primo è momentaneamente in pausa: si tratta di un piccolo sito su cui ho reso disponibili gli script utilizzati per raccogliere i dati relativi ai contest "Miglior Autore della Settimana" e "OdB Engagement Contest".

Il sito è già raggiungibile a questo link e consente sia di trovare subito tutti i contest summenzionati, oltre a quello relativo ad "Unto&Bisunto", nonchè di accedere agli script che ho creato.



Il sito è ancora un "work in progress", ma è già funzionante e consente a @libertycrypto27 e @bencwarmer di raccogliere i dati di cui hanno bisogno senza essere obbligati a scaricare, aggiornare ed eseguire in locale i miei script (a meno che non vogliano farlo per motivi prestazionali).

Voglio però aggiungere altre funzioni e vedere se posso migliorare la mia padronanza di Streamlit così da rendere il sito più accattivante e rifinito.

Come dicevo poco sopra, però, questo progetto è temporaneamente in pausa perchè nel mentre che lavoravo mi è venuta in mente anche un'altra idea e non ho potuto fare a meno di mettermi subito a creare nuove ed intricate linee di codice (intricate perchè non ci si capisce nulla 🤣).


HiveSQL

Al centro di questo secondo si trova HiveSQL, il database creato e gestito da @arcange, che raccoglie tutti i dati relativi ad Hive e consente di accedervi velocemente, facilmente e, per ora, gratuitamente.

vale quindi supportare la relativa proposta per far sì che questo servizio continui ad essere gratuito.

Il mio obiettivo è quello di sfruttare questo enorme database per raccogliere una mole enorme di dati relativi agli utenti di Hive, così da poterli poi manipolare, analizzare, catalogare ed usare (i dati, non gli utenti 😂).

Cosa voglio fare poi con questi dati per ora resterà un segreto, perchè devo capire se la cosa è fattibile e se può generare un qualche interesse: un tempo c'era qualcosa di analogo a ciò che vorrei fare, ma i tempi cambiano e non è detto che una cosa che funzionava anni fa possa farlo ancora oggi.

In ogni caso per me si tratta prima e soprattutto di una sfida: avere a che fare con HiveSQL significa dover imparare ad estrarre dati da un database e manipolarli poi in maniera efficace, trasformando un lavoro che avrebbe richiesto mesi in qualcosa che può essere completato in poche decine di secondi.

La sfida più ardua però si sta rivelando la prima, ossia estrarre correttamente i dati che mi servono da HiveSQL.


        SQLCommand = f"""
        SELECT author, body_length, parent_author, depth, LEFT(CONVERT(VARCHAR(MAX), body), 55) AS body
        FROM dbo.Comments
        WHERE created > ? 
            AND depth > 0 
            AND parent_author NOT IN ({parent_authors_placeholders})
            AND author NOT IN ({authors_placeholders});
        """

        cursor.execute(SQLCommand, [time] + invalid_parent_authors + invalid_authors)
        every_comment = cursor.fetchall()

Una query come questa sopra è infatti ancora complicata per me da comprendere a pieno e per la creazione di questo script sto facendo un (ab)uso di ChatGPT direi anche troppo esagerato: cerco sempre di capire i risultati che mi propone, ma stavolta ammetto di averlo usato in modo massiccio per risolvere un sacco di problemi che, altrimenti, mi avrebbero richiesto, come minimo, ore ed ore per essere risolti.

La mia speranza è che comunque qualcosa mi resti in testa, in modo da accrescere le mie conoscenze in ambito di Python e poter, un domani, passare a realizzare progetti ancora più ambiziosi!


cover realizzata con ChatGPT ed editata con GIMP

a supporto della community #OliodiBalena, il 3% delle ricompense di questo post va a @balaenoptera

Se sei arrivato a leggere fin qui, grazie! Se hai voglia di lasciare un upvote, un reblog, un follow, un commento... be', un qualsiasi segnale di vita, in realtà, è molto apprezzato!

Sort:  

Ottimo lavoro e grazie anche per lo script!!! 💪🏻❤️