How to Connect MySQL to Tableau: A Guide for BI Professionals

It is necessary to have a reliable and efficient way to transfer data from databases to the BI tool. MySQL, one of the most popular open-source relational database management systems, comes in here. This article will explore how to connect MySQL to Tableau and share data seamlessly between the two.

The post How to Connect MySQL to Tableau: A Guide for BI Professionals appeared first on Devart Blog.

Planet MySQL

You Should Enable Gmail’s New ‘Enhanced Safe Browsing’

https://i.kinja-img.com/gawker-media/image/upload/c_fill,f_auto,fl_progressive,g_center,h_675,pg_1,q_80,w_1200/3f8164b4ea7d53007743bee156ca7d42.jpg

Google’s had an Enhanced Safe Browsing feature in Chrome since 2019—a set of privacy features to help protect against phishing and malware attacks. Basically, if a link doesn’t seem quite right, Google will warn you about it. Recently, they finally brought the feature directly into Gmail.

Here’s how Enhanced Safe Browsing mode works

Enhanced Safe Browsing checks the links and attachments in your Gmail account with its own database of known scam links, where a website pretends to be real to steal your personal information (also known as phishing). Google has a massive database of such bad actors, and it’s updated every 30 minutes. Once the feature is enabled, Gmail will scan incoming emails and attachment downloads against that database and warn you if something looks suspicious.

How to enable Enhanced Safe Browsing on Gmail

If you’re already logged in to your Google account, simply open this link in a new tab and enable the Enhanced Safe Browsing feature from there. Alternatively, you can open your Google Account page and go to Security > Manage Enhanced Safe Browsing.

When you enable this feature in your Google account, it will be enabled across other Google products as well, like Chrome. And in Chrome, this feature extends to Chrome extensions and file downloads.

The downsides of using Enhanced Safe Browsing

The only big downside to using Enhanced Safe Browsing is the sheer amount of personal data that Google will be able to access. It’ll be able to check all the links that come through your Gmail account, and if you use Chrome, that includes links clicked, files downloaded, and extensions installed.

Of course, Google says this data is used only to improve your data security when you’re logged in, and after a short time, the data is fully anonymized. But anonymizing data isn’t perfect—it can still be linked to social media profiles, as one Princeton study illustrates.

If you’re okay with that potential risk, go ahead and enable the feature. It might also be worth recommending to others in your life too, if you think they’re the type of user particularly susceptible to things like phishing scams and malware attacks.

[ZDNET, CNET]

Lifehacker

Introduction to PandasAI: The Generative AI Python Library

https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2023/07/manipulating-datasets-and-dataframes-with-pandasai-featured-image.jpg

Pandas is the most predominant library for manipulating datasets and dataframes. This has been the norm for a long time. But with the advancement in artificial intelligence, a new open-source library called PandasAI is developed that adds generative AI capabilities to Pandas.

PandasAI does not replace Pandas. Instead, it gives its generative AI capabilities. In this way, you can perform data analysis by chatting with PandasAI. It then abstracts what is happening in the background and provides you with the output of your query.

Installing PandasAI

PandasAI is available via PyPI (Python Package Index). Create a new virtual environment if you are using a local IDE. Then use the pip package manager to install it.

 pip install pandasai 

You may encounter a dependency conflict error similar to the one shown below if you are using Google Colab.

Do not downgrade the IPython version. Just restart your runtime and run the code block again. This will resolve the issue.

Understanding the Sample Dataset

The sample dataset you will manipulate with PandasAI is the California Housing Prices dataset from Kaggle. This dataset contains information about housing from the 1990 California census. It has ten columns that provide statistics about these houses. The data card to help you learn more about this dataset is available on Kaggle. Below are the first five rows of the dataset.

Each column represents a single statistic of a house.

Connecting PandasAI to the Large Language Model

To connect PandasAI to a large language model (LLM) like that of OpenAI, you need access to its API key. To obtain one, proceed to the OpenAI platform. Then log in to your account. Select API under the options page that appears next.

After that, click on your profile and select the View API keys option. On the page that appears next click Create new secret key button. Lastly, name your API key.

OpenAI will generate your API key. Copy it as you will need it while connecting PandasAI with OpenAI. Make sure you keep the key secret as anyone with access to it can make calls to OpenAI on your behalf. OpenAI will then charge your account for the calls.

Now that you have the API key, create a new Python script and paste the code below. You won’t need to change this code as most of the time you will be building on it.

 import pandas as pd
from pandasai import PandasAI


df = pd.read_csv("/content/housing.csv")


from pandasai.llm.openai import OpenAI
llm = OpenAI(api_token="your API token")

pandas_ai = PandasAI(llm)

The above code imports both PandasAI and Pandas. It then reads a dataset. Finally, it Instantiates the OpenAI LLM.

You are now set to converse with your data.

Performing Simple Tasks Using PandasAI

To query your data, pass your dataframe and your prompt to the instance of PandasAI class. Start by printing the first five rows of your dataset.

 pandas_ai(df, prompt='What are the first five rows of the dataset?') 

The output of the above prompt is as follows:

This output is identical to that of the dataset overview earlier. This shows that PandasAI produces correct results and is reliable.

Then, check the number of columns present in your dataset.

 pandas_ai(df, prompt='How many columns are in the dataset? ') 

It returns 10 which is the correct number of columns in the California Housing dataset.

Checking whether there are missing values in the dataset.

 pandas_ai(df, prompt='Are there any missing values in the dataset?') 

PandasAI returns that the total_bedrooms column has 207 missing values, which is again correct.

There are a lot of simple tasks that you can achieve using PandasAI, you are not limited to the ones above.

Performing Complex Queries Using PandasAI

PandasAI does not only support simple tasks. You can also use it to carry out complex queries on the dataset. For example, in the housing dataset, if you want to determine the number of houses that are located on an island, have a value of more than 100,000 dollars, and have more than 10 rooms you can use the prompt below.

 pandas_ai(df,prompt= "How many houses have a value greater than 100000,"
                    " are in an island and total bedrooms is more than 10?")

The correct output is five. This is the same result that PandasAI outputs.

Complex queries might take a data analyst some time to write and debug. The above prompt only takes two lines of natural language to accomplish the same task. You just need to have in mind exactly what you want to accomplish, and PandasAI will take care of the rest.

Drawing Charts Using PandasAI

Charts are a vital part of any data analysis process. It helps the data analysts visualize the data in a human-friendly manner. PandasAI also has a chart drawing feature. You just have to pass the dataframe and the instruction.

Start by creating a histogram for each column in the dataset. This will help you visualize the distribution of the variables.

 pandas_ai(df, prompt= "Plot a histogram for each column in the dataset") 

The output is as follows:

PandasAI was able to draw the histogram of all the columns without having to pass their names in the prompt.

PandasAI can also plot charts without you telling it explicitly which chart to use. For example, you may want to find out the correlation of the data in the housing dataset. To achieve this you can pass a prompt as follows:

 pandas_ai(df, prompt= "Plot the correlation in the dataset") 

PandasAI plots a correlation matrix as shown below:

The library chooses a heatmap and plots a correlation matrix.

Passing in Multiple Dataframes to the PandasAI Instance

Working with multiple dataframes can be tricky. Especially for a person who is new to data analysis. PandasAI bridges this gap as all you need to do is pass both dataframes and start using prompts to manipulate the data.

Create two dataframes using Pandas.

 employees_data = {
   'EmployeeID': [1, 2, 3, 4, 5],
   'Name': ['John', 'Emma', 'Liam', 'Olivia', 'William'],
   'Department': ['HR', 'Sales', 'IT', 'Marketing', 'Finance']
}

salaries_data = {
   'EmployeeID': [1, 2, 3, 4, 5],
   'Salary': [5000, 6000, 4500, 7000, 5500]
}

employees_df = pd.DataFrame(employees_data)
salaries_df = pd.DataFrame(salaries_data)

You can ask PandasAI a question that cuts across both of the dataframes. You only have to pass both dataframes to the PandasAI instance.

 pandas_ai([employees_df, salaries_df], "Which employee has the largest salary?")

It returns Olivia which is again the correct answer.

Performing data analysis has never been easier, PandasAI lets you chat with your data and analyze it with ease.

Understanding the Technology That Powers PandasAI

PandasAI simplifies the process of data analysis hence saving a lot of time for data analysts. But it abstracts what is happening in the background. You need to familiarize yourself with generative AI so that you can have an overview of how PandasAI is operating under the hood. This will also help you keep up with the latest innovations in the generative AI domain.

MakeUseOf

What Is Plex? A Beginner’s Guide

https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2023/07/plex-on-an-iphone-ipad-and-mac.jpg

Not as popular as Netflix or as specific as Crunchyroll, Plex is a not-so-well-known but versatile entertainment platform that serves many core functions. It’s a cross-platform media streaming service you can use to watch live TV, find titles, stream music, and broadcast your own media on a server.

Plex might be a little difficult to navigate as a new user, but we’ve got you covered. Keep reading to learn how to use Plex’s core features to work and understand its pricing plans.

What Is Plex?

On the surface, Plex looks like another Netflix alternative, but don’t be deceived. While it’s a streaming platform, most of the titles you’ll find here to stream are old or low-budget films and TV shows. But they’re all free.

You could also find newer titles that aren’t available for streaming on Plex. After finding them, add them to your Watchlist, and see where you can currently stream them in its Watch from these locations section in the film description. If you have a Plex Media Server with the movie in its catalog, you’ll find the server with the movie listed as a source.

You can also stream music from Plex by clicking Music on the side menu. However, you will need a Tidal subscription since all the music on Plex is from Tidal.

However, most people commonly use Plex for its media server. With a Plex Media Server, you can create a server that will source videos, photos, and music from the host device and broadcast it online for all other devices using your account.

Plex Also Has Live TV Channels

Similar to cable TV, Plex has “channels” you can connect to and watch. These channels number over a hundred in various niches, categories, and languages. This is the only way you can watch certain shows like The Joy of Painting with Bob Ross; it’s not in the Free On Demand category—you’ll only find it only on the Bob Ross Channel.

The Live TV section is in the left-side menu. After you select it, you can use the tabs to choose what categories you would like, such as Entertainment, Movies, Reality, News, Kids, etc. Learn more in our dedicated guide on how to watch free live TV channels on Plex.

Much like traditional cable TV, you can’t rewind or pause Plex’s Live TV channels. They also have break times and airing times, so you might not be able to watch your favorite channel every time you’d like.

Most Plex veterans use it primarily for its server function. You can download a Plex Media Server on your laptop, choose what folders you would like it to access, and all your devices will be able to access it.

Here’s a quick way to get started:

  1. Download a Plex Media Server from Plex’s website, install it, and launch it.
  2. Open Settings in the Plex app by clicking the wrench in the top-right.
  3. Scroll to the Manage section and click Libraries.
  4. Select Add Library, choose your category of media, click Next, and select Add Library.

Anytime you want to watch something from your media server, click More in the side menu to see your linked device’s media.

But this is only a rudimentary way to turn a computer into a Plex server; there’s a way to convert an old computer to a dedicated Plex Media Server.

Plex helps organize your media after it scans them and adds them to your collection. Based on the available metadata, it will add artwork, descriptions, and song lyrics. It’s a pretty good way to organize your media.

You can also connect a tuner or antenna to your Plex Media Server to tap into over-the-air signals in your location.

How Much Does Plex Cost?

Plex takes pride in the fact that most of its core features are completely free—no subscriptions required. That said, it has a Plex Pass, which could cost you $4.99/month, $39.99/year, or a lifetime cost of $119.99.

But we’re sure you’re wondering why you would ever have to pay for a Plex Pass. Here are some of the more interesting features you get when your pay for Plex:

  • Better playback through hardware acceleration and transcoding for media on your server with a Plex Pass. That means you could have more devices streaming from your Plex Media Server without compromising your video quality.
  • Plex also restricts your media playback and watermarks photos on the Android and iOS apps, but getting a Plex Pass removes all such restrictions (this doesn’t apply to TV apps or the web app).
  • The song lyrics feature we discussed earlier is locked behind Plex’s paywall.
  • You get to skip credits and intros in movies in your library with a Plex Pass.
  • Get extra content for movies in your libraries, such as interviews and behind-the-scenes.

The people who stand to gain the most from the Plex Pass are those with multiple devices and users who would like to stay connected to the Plex Media Server without compromising too much. However, more casual users who plan to mostly use this individually might not see any need for investing in a Plex Pass.

What Devices Can You Use to Stream Plex?

As you may have guessed, Plex has a versatile cross-platform ecosystem. Here are all the places you can access Plex:

  • Browsers (Chrome, Firefox, Edge, and Safari) via the web app.
  • Laptops and desktops running macOS, Windows, or Linux.
  • Android phones and tablets.
  • iPhones and iPads.
  • Smart TVs (Samsung, LG, Hisense, Vizio, etc.).
  • Android TVs.
  • Apple TVs.
  • Chromecast.
  • Roku.
  • Sonos.
  • Amazon Alexa.
  • PS4, PS5, Xbox 360, Xbox One, and Xbox X|S.

However, some of these might require you to have a Plex Pass. If you don’t want that, you may have to pay a one-time $5 fee to activate the device to have full access to your Plex Media Server.

Use Plex to Watch Anything Anywhere

If you have most of your favorite movies, songs, and films on a PC somewhere, and you’re tired of lugging a hard drive around, it’s time to invest in Plex. You could bite the bullet and buy a lifetime Plex subscription or use its free version, but you can now set up a media server to connect to wherever you are.

MakeUseOf

Laravel Herd

https://laravelnews.s3.amazonaws.com/images/laravel-herd-featured.png

Laravel Herd is a blazingly fast, native Laravel and PHP development environment for macOS. It includes everything you need to start Laravel development, including PHP and nginx. Once you install Herd, you’re ready to start developing with Laravel:

Herd will install tools you need for development, like Composer, the Laravel installer, and more. You can also seamlessly migrate to Herd from Valet—Herd will automatically migrate existing Valet preferences:

Laravel Herd Valet migration prompt

Herd is a native macOS application so it will not work with Windows or Linux. It also uses static binaries and comes with a lot of PHP extensions that should fit most projects, but unfortunately, there’s no way to install additional extensions. Here’s a list of supported extensions at this time:

intl, pdo_sqlite, sqlite3, curl, openssl, tokenizer, bcmath, bz2, calendar, dba, ftp, iconv, mysqli, mbstring, xml, simplexml, ctype, dom, pdo, filter, session, zlib, fileinfo, pdo_mysql, posix, sockets, shmop, sodium, sysvmsg, sysvsem, sysvshm, gd, zip, gmp, redis, xmlwriter, phar, exif, xmlreader, readline, pcntl, soap, imagick, ffi, opcache

Is Valet going away? According to Matt Staufer, the short answer is no; currently, Herd is using a Valet fork and will soon be powered by Valet:

Get started with Herd today at herd.laravel.com. Also, there’s documentation to help you get started and troubleshoot things if you run into any issues.

Laravel News

How to Use pstree to Display Running Linux Processes as a Tree

https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2023/07/tree-branches.jpg

If you use Linux, you’ve most likely used ps, top, or htop to view currently running processes on the system. While these programs are useful, they don’t show the relationship of processes to each other.

pstree is a program that visualizes Linux processes as a tree. Here’s how you can install and use it on Linux.

What Is pstree?

pstree is a program that shows the processes as a tree-like structure. The parent processes are the “trunk” and the child processes are branches.

Using pstree for the first time reveals how Linux processes work. All Linux processes have the init process, which is systemd on most major mainstream distros, as their common ancestor.

How to Install pstree on Linux

pstree is such a useful utility that there’s a good chance it’s already installed on your system. If you try to run it and it isn’t, it’s available through your package manager. It’s part of the psmisc suite of utilities.

To install it on Debian and Ubuntu, type:

 sudo apt install psmisc 

To install pstree on Arch Linux:

 sudo pacman -S psmisc 

And on the Red Hat family of distros:

 sudo dnf install psmisc 

Use pstree to View Linux Processes as a Tree

Running pstree is simple. Just type pstree at the command line. You’ll see a tree of all the processes running on your system.

Supplying a username as an argument will show all the processes that the user owns. For example, to see a tree of the superuser’s processes:

 pstree root 

As with many other Linux programs, pstree has command-line options. You can see the PIDs of the processes with the -p option:

 pstree -p 

To highlight the current process, that is, your current shell, use the -h option.

 pstree -h 

You can highlight a certain PID with the -H (capital H) option, followed by the PID number:

 pstree -H [PID] 

You can get a color-coded representation of the age of the processes with the -C option, followed by the age value. This is currently the only argument that this option takes.

Processes spawned in the last 60 seconds will be displayed in green. Similarly, yellow represents processes that were started an hour ago. The remaining processes will be in red.

 pstree -C age 

pstree gives you a hierarchical tree-like view of your running Linux processes, true to its name. You can see how your processes flow out of the init process, and you can customize your view with different options.

Linux’s procfs also lets you see information on Linux processes right from the file system.

MakeUseOf

Hearing Aids May Cut Risk of Cognitive Decline By Nearly Half

An anonymous reader quotes a report from the Washington Post: A study published Monday in the Lancet found that the use of hearing aids can reduce the risk of cognitive decline by about half — 48 percent — for adults with more risk factors for dementia, such as elevated blood pressure, higher rates of diabetes, lower education and income, and those living alone. The study was presented at the Alzheimer’s Association International Conference in Amsterdam. […] Over a three-year period, the randomized controlled trial studied nearly 1,000 older adults, ages 70 to 84, in four sites in the United States. The participants included older adults in an ongoing study of cardiovascular health — Atherosclerosis Risk in Communities (ARIC) — and others who were healthier than the ARIC adults; both groups were from the same communities at each site.
When the two groups were combined, use of hearing aids was shown to have no significant effect on slowing cognitive changes. When the group at higher risk of dementia, the ARIC group, was analyzed separately, however, researchers found that hearing intervention — counseling with an audiologist and use of hearing aids — had a significant impact on reducing cognitive decline. Those considered at high risk for dementia were older and had lower cognitive scores, among other factors. When the groups were combined, the slower rate of cognitive decline experienced by the healthier participants may have limited any effect of hearing aids, the researchers suggested. Whether hearing treatment reduces the risk of developing dementia in the long term is still unknown. "That’s the next big question — and something we can’t answer yet," said Lin, who is also director of the Cochlear Center for Hearing and Public Health at Johns Hopkins University. He said he and his colleagues are planning a long-term follow-up study to attempt to answer that question.
There have many studies over the past decade to try to determine why people with hearing loss tend to have worse cognition, said Justin S. Golub, an associate professor of otolaryngology at Columbia University Irving Medical Center. One theory is that it requires a lot of effort for people with hearing loss to understand what others are saying — and that necessary brainpower leaves fewer cognitive resources to process the meaning of what was heard, he said. Another theory relates to brain structure. Research has shown that the temporal lobe of people with hearing loss tends to shrink quicker because it is not receiving as much auditory input from the inner ear. The temporal lobe is connected to other parts of the brain, and "that could have cascading influences on brain structure and function," said Golub, who was not part of the Lancet study. A third theory is that people with hearing loss tend to be less social and, as a result, have less cognitive stimulation, he said.


Read more of this story at Slashdot.

Slashdot

Eloquent hasMany: Get Parent with Latest Row of Relationship – 5 Ways

https://laraveldaily.com/storage/455/Copy-of-ModelpreventLazyLoading();-(4).png

Eloquent has a lot of “hidden gems”. In this tutorial, let’s see how we can get the latest record from the hasMany Relationship in five different ways.

Let’s imagine we have transactions, and every transaction belongs to a category. The goal is to list the categories with the latest transaction for each of them.

While listing different methods, I will start from the worst one and go to the best method.


Method 1: Blade – Wrong Way (N+1 Query)

The first method is the most straightforward – to take care of the relationship in the Blade. But it’s the worst in terms of performance.

In the Controller, we just get the categories:

class HomeController

{

public function index()

{

$categories = Category::take(10)->get();

 

return view('categories', compact('categories'));

}

}

In the Blade, while viewing those categories, we load the latest transaction and take the first record.

<ul>

@foreach($categories as $category)

<li>

(last transaction: )

</li>

@endforeach

</ul>

The result looks similar to the below image.

latest record result

But with this method, we have an N+1 problem, which makes a database query for every category to get the transaction.

latest record n+1 problem


Method 2: Eager Loading with() – Still Wrong

In the second method, we fix the N+1 problem from the first method. Usually, it is done using the eager loading.

We load the transactions in the Controller using the with method.

class HomeController

{

public function index()

{

$categories = Category::with('transactions')->take(10)->get();

 

return view('categories', compact('categories'));

}

}

And then, in the Blade, we don’t need to query the transactions. We can access the transactions from the collection and sort and get the first from that.

<ul>

@foreach($categories as $category)

<li>

(last transaction: )

</li>

@endforeach

</ul>

But this gives other problems. In the first method, we have ten transactions and categories loaded from the DB.

first method loaded records

After a refresh, we have fewer queries which is great. Well, kinda.

eager loaded records

But now we have loaded all the transactions for each category, which can get heavy on the RAM usage. This means we have improved performance in one place but decreased in another.

many loaded models


Method 3: Subquery

The third method is if you need precisely one field, so you don’t need all the transaction Model, for that, you might write a subquery.

class HomeController

{

public function index()

{

$categories = Category::addSelect(['latest_transaction_amount' => Transaction::select('amount')->whereColumn('category_id', 'categories.id')->latest()->take(1)])

->take(10)

->get();

 

return view('categories', compact('categories'));

}

}

In the query, we named the variable as latest_transaction_amount, so we just can use it in the Blade:

<ul>

@foreach($categories as $category)

<li>

(last transaction: )

</li>

@endforeach

</ul>

This way, we have only one query, but it can only be used when you need only one column from the relation table.

subquery


Method 4: Special Relation Method

But if you need the whole record, there is still a better way. Instead of using a transactions relation in the Category Model, we could create a special relation that would return the latest row.

class Category extends Model

{

// ...

 

public function transactions()

{

return $this->hasMany(Transactions::class);

}

 

public function latest_transaction()

{

return $this->hasOne(Transaction::class)->latest();

}

}

In the Controller, we need to eager load this relationship.

class HomeController

{

public function index()

{

$categories = Category::with('latest_transaction')->take(10)->get();

 

return view('categories', compact('categories'));

}

}

And in the Blade, we don’t need to sort or do anything else.

<ul>

@foreach($categories as $category)

<li>

(last transaction: )

</li>

@endforeach

</ul>

This makes only five queries which are good, but still loads all the transactions.

hasOne latest relationship


Method 5: New latestOfMany()

Since Laravel 8.42, there is a better way. It’s the same thing as latest_transaction in the fourth method, but instead of the latest, we need to use latestOfMany.

class Category extends Model

{

// ...

 

public function transactions()

{

return $this->hasMany(Transactions::class);

}

 

public function latest_transaction()

{

return $this->hasOne(Transaction::class)->latestOfMany();

}

}

So the old query looks like this:

select * from `transactions` where `transactions`.`category_id` in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) order by `created_at` desc

And after a refresh, we have much less loaded Models because we select only one transaction for each category.

hasOne latest of many query

This relation has more methods. You can check them in the Laravel documentation or check the Pull Request at the GitHub.

Laravel News Links

Introducing the MySQL Configurator tool

https://orasites-prodapp.cec.ocp.oraclecloud.com/content/published/api/v1.1/assets/CONT04A265851B14480BB7F962D7CB173DD0/native?cb=_cache_8b94&channelToken=32954b2a813146c9b9a4fa99364eba8eThis blog post introduces the new MySQL Configurator tool, available starting with MySQL Server 8.1.0.Planet MySQL

Racing Hot Wheels Down a Closed Water Slide

https://theawesomer.com/photos/2023/07/hot_wheels_water_slide_t.jpg

Racing Hot Wheels Down a Closed Water Slide

Link

This is the stuff that kid dreams are made of. DreamTrack Builder headed to the top of an abandoned water slide and raced a bunch of Hot Wheels cars down its chute. A chase car sat at the back of the pack towing a GoPro camera. He also did a nighttime race and one with 50-cars.

The Awesomer