Featured Post

8 Ways to Optimize AWS Glue Jobs in a Nutshell

  Improving the performance of AWS Glue jobs involves several strategies that target different aspects of the ETL (Extract, Transform, Load) process. Here are some key practices. 1. Optimize Job Scripts Partitioning : Ensure your data is properly partitioned. Partitioning divides your data into manageable chunks, allowing parallel processing and reducing the amount of data scanned. Filtering : Apply pushdown predicates to filter data early in the ETL process, reducing the amount of data processed downstream. Compression : Use compressed file formats (e.g., Parquet, ORC) for your data sources and sinks. These formats not only reduce storage costs but also improve I/O performance. Optimize Transformations : Minimize the number of transformations and actions in your script. Combine transformations where possible and use DataFrame APIs which are optimized for performance. 2. Use Appropriate Data Formats Parquet and ORC : These columnar formats are efficient for storage and querying, signif

How to Call SQL Query from Python

Python's top supported database is MySQL. You can run SQL queries from Python. Here're best examples of how to connect to MYSQL and access MYSQL tables from Python.

Read: How to Print String in Next Line Easily

Here are Steps

  1. Import MySQL connecter
  2. Give user id, password details
  3. Issue SQL query

Python Logic to import MySQL connector

import mysql.connector

Note: If the MySQL connecter not installed in python, you need to install it using the below command.

pip3 install mysql-connector-python --allow-external mysql-connector-python

How to Call SQL Query from Python

Supply user id and Password

conn=mysql.connector.connect(user='root', password='password', host='localhost', database='sakila')


Issue SQL Query

mycursor.execute("show tables") # you won't see any result. You need to give print.


mycursor.execute("select * from customer") # you won't see any result. You need to give print.


This way you can issue SQL queries in Python.

Read: Top 100 Hadoop Interview Questions 1 of 4


Popular posts from this blog

How to Fix datetime Import Error in Python Quickly

How to Check Kafka Available Brokers

SQL Query: 3 Methods for Calculating Cumulative SUM