Pawandeep Kaur has Published 32 Articles

How to plot a graph in Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 23-Aug-2023 21:59:14

50K+ Views

Graphs in Python can be plotted by using the Matplotlib library. Matplotlib library is mainly used for graph plotting.You need to install matplotlib before using it to plot graphs. Matplotlib is used to draw a simple line, bargraphs, histograms and piecharts. Inbuilt functions are available to draw all types of ... Read More

How to read a text file in Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:39:07

31K+ Views

A text file is the file containing simple text. Python provides inbuilt functions to read, create and write text files. We will discuss how to read a text file in Python.There are three ways to read a text file in Python −read() − This method reads the entire file and ... Read More

Explain and show the use of UNION in MySQL using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:37:11

715 Views

The UNION statement is used to combine the results of the two SELECT queries without repeating the duplicate values. If both the SELECT queries return same row, it is listed only once.To perform the UNION on two select statements, The number of columns returned must be sameThe datatypes of the ... Read More

How to perform arithmetic across columns of a MySQL table using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:32:14

529 Views

The arithmetic operations as the name suggests are used to perform the operations such as additon, subtraction, division, multiplication or modulus.The arithmetic operations are operated on the numeric data in your table.SyntaxTo perform additionSELECT op1+op2 FROM table_nameHere, the op1 and op2 are the column names or the numeric values. If ... Read More

How to add a column to a MySQL table in Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:31:53

4K+ Views

It may be sometimes required to add a new column in a existing table. Suppose we have a “Students” table with columns such as Name, Age, Roll no. We want to add a new column “Address” into our existing table.This can be done by using the ALTER command. The ALTER ... Read More

How can you test if some record exists or not in a MySQL table using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:31:34

7K+ Views

We may at times need to check if a particular record exists in a table or not.This can de done using the EXISTS statement. The EXISTS statement returns true if the following subquery returns one or more records.SyntaxSELECT * FROM table_name WHERE EXISTS(sub_query)The subquery if returns one or more rows, ... Read More

How to show all the tables present in the database and server in MySQL using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:31:12

15K+ Views

We may sometimes require to get the list of all the tables present in our database. This can be done by using the SHOW TABLES command.The SHOW TABLES command is used to display the table names in a database as well as the server.SyntaxTo show the tables present in a ... Read More

How to count SQL table columns using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:30:12

2K+ Views

It may be required to count the number of columns present in a SQL table.This is done using count(*) function with information_schema.columns and the WHERE clause. The WHERE clause is used to specify the name of the table whose columns are to be counted.SyntaxSELECT COUNT(*) FROM information_schema.columns WHERE table_name= ‘your_table_name’Steps ... Read More

How to add comment to column in MySQL using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:29:20

412 Views

A comment is a readable explanation provided about something. The comments in the code are provided to explain the purpose of the code staement used. This enables the outside person to understand the need and use of that particular code.The comments are ignored by the compilers and are not executed. ... Read More

How to use IF statement in MySQL using Python?

Pawandeep Kaur

Pawandeep Kaur

Updated on 10-Jun-2021 13:19:10

2K+ Views

IF statement is a conditional statement in python. It checks for a particular condition and performs some action accordingly.Here, we will discuss the use of IF statement using python to interact with the sql database.SyntaxIF(condition, value_if_true, value_if_false)The IF statemen tcan be used with the SELECT clause to perform selection based ... Read More

Advertisements