Posts

Showing posts from September, 2019

Youtube-dl cheatsheet

Youtube-dl cheatsheet Hello fellow coders… Today I am going to post something different. Its about a command-line based youtube downloader called youtube-dl . If you dont know about it, please go and check their homepage . This gives you instructions to install it correctly. So today I am going to post some cheats you will need to download best youtube videos quickly. One more important thing, there are no configuration settings to be done before or after installing youtube-dl . Downloading a single video When you need to download a single youtube video, you just type : youtube-dl youtube-video-url This will download the best quality video available. But if you can select specific video quality. I will describe it later. Downloading a playlist When you are interested about a certain youtube play list and want to download, youtube-dl gives an easy way to do it. You just have to use : youtube-dl -cit youtube-playlist-url Download specific videos from a

How to get MySQL data using sql.Query() in golang

How to get MySQL data using sql.Query() in golang Hello fellow coders… This is my first golang post here on blogger, I had been learning it for last a few months and now developing my own hobby project. Today I am going to share how to get data from MySQL table using sql.Query() function. First thing is connecting to MySQL database, to do so, I have used a separate function. func dbConn() (db *sql.DB) { db, err := sql.Open("mysql", "root:my_password@tcp(127.0.0.1:3306)/my_database") if err != nil { log.Println("Can not open database connection") } return db } And in my function where I need to connect with database, I use db := dbConn() defer db.Close() Always remember to close the database connection. And in this function, I am trying to get vehicle_ids from table. Here I have used a variable to hold the string query. It makes code more readable and clean. Here db.Query() returns a pointer to all available MySQL rows,