Thursday , September 19 2024

Machine Learning

Creating NumPy Array

Creating NumPy Array

2 – Create an Array Create a NumPy Array¶The learning objectives of this section are: Understand advantages of vectorised code using NumPy (over standard python ways) Create NumPy arrays Convert lists and tuples to NumPy arrays Create (initialise) arrays Compare computation times in NumPy and standard Python lists NumPy Basics¶NumPy …

Read More »

Introduction to NumPy

Introduction to NumPy

1 – Introduction to Numpy Introduction to NumPy¶NumPy (numerical Python) is a library that consists of multidimensional array objects and a set of routines for processing them. NumPy allows you to perform mathematical and logical operations on arrays. This tutorial walks you through the fundamentals of NumPy, including its design …

Read More »

Python MySQL Installation

MySQL Installation

1 Python MySQL Installation Python MySQL Database¶SQL stands for Structured Query Language and is a widely used programming language for managing relational databases. Python can be used in database applications. One of the most popular databases is MySQL. Python needs a MySQL driver to access the MySQL database. pip install …

Read More »

Python MYSQL Create Database

Python MYSQL Create Database

2 Python MySQL Create Database Python MySQL Create Database¶To create a database in MySQL, use the “CREATE DATABASE” statement: Note: In MySQL, it’s mandatory to put a semicolon (;) at the end of a statement, which denotes the termination of a query. However, MySQL Connector/Python automatically appends a semicolon at …

Read More »

Python MySQL Create Table

Python MySQL Create Table

3 Python MySQL Create Table Python MySQL Create Table¶To create a table in MySQL, use the “CREATE TABLE” statement. Make sure you define the name of the database when you create the connection In [4]: import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", passwd="", database="itronix" ) mycursor = mydb.cursor() mycursor.execute("CREATE TABLE student …

Read More »

Python MySQL Insert Into Table

Python MySQL Insert Into Table

4 Python MySQL Insert Into Table Python MySQL Insert Into Table¶To fill a table in MySQL, use the “INSERT INTO” statement. In [8]: import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", passwd="", database="itronix" ) mycursor = mydb.cursor() name = input("Enter Name:") address = input("Enter Address:") sql = "INSERT INTO customers (name, address) …

Read More »

Python MySQL Select From

Python MySQL Select From

5 Python MySQL Select From Python MySQL Select From Table¶To select from a table in MySQL, use the “SELECT” statement: In [11]: import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", passwd="", database="itronix" ) mycursor = mydb.cursor() mycursor.execute("SELECT * FROM customers") myresult = mycursor.fetchall() for x in myresult: print(x) (1, 'Karan', 'Ludhiana') (2, …

Read More »

Python MySQL Where

Python MySQL Where

6 Python MySQL Where Python MySQL Where¶ In [14]: import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", passwd="", database="itronix" ) mycursor = mydb.cursor() sql = "SELECT * FROM customers WHERE address ='Ludhiana'" mycursor.execute(sql) myresult = mycursor.fetchall() for x in myresult: print(x) (1, 'Karan', 'Ludhiana') Wildcard Characters¶You can also select the records that …

Read More »

Python MySQL Order By

Python MySQL Order By

7 Python MySQL Order By Python MySQL Order By¶Sort the Result Use the ORDER BY statement to sort the result in ascending or descending order. The ORDER BY keyword sorts the result ascending by default. To sort the result in descending order, use the DESC keyword. Python MySQL Order by …

Read More »

Python MySQL Delete From By

Python MySQL Delete From By

8 Python MySQL Delete From By Python MySQL Delete From By¶ You can delete records from an existing table by using the “DELETE FROM” statement: In [19]: import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", passwd="", database="itronix" ) mycursor = mydb.cursor() sql = "DELETE FROM customers WHERE address = 'Otawa 4'" mycursor.execute(sql) …

Read More »