Category

Python

Category

Creating tables in the database to store data. Before creating tables, we have to select a database first. Run the following code, to select realprogrammer database which we have selected. ## Connecting to the database import mysql.connector as mysql db = mysql.connect( host=”localhost”, user=”root”, passwd=”root@123″, db=”realprogrammer” ) cursor = db.cursor() ## creating a table called ‘users’ in the ‘datacamp’ database cursor.execute( “CREATE TABLE user (name VARCHAR(255), user_name VARCHAR(255))”)

Create a folder and go inside of the folder mkdir python_database cd python_database Installation pip install mysql-connector-python Now Create file db.py ## Connecting to the database import mysql.connector as mysql db = mysql.connect( host=”localhost”, user=”root”, passwd=”root@123″ ) print(db)

1) What is Python? What are the advantages of utilizing Python? Python is an interpreted, high-level, general-purpose programming language. Python’s design philosophy emphasizes code readability with its notable use of significant whitespace. Its language constructs and object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects. Python is dynamically typed and garbage-collected. It supports multiple programming paradigms, including procedural, object-oriented, and functional programming. Python is often described as a “batteries…

How To Install Django 2 In Mac First, we need to install python3 in our system -> brew install python3 Now check the version of python -> python3 Install pip package management system. -> sudo easy_install pip Install virtualenv for python. -> sudo pip install virtualenv -> virtualenv ven -> cd venv -> source bin/activate Install Django 2 -> pip install django==2.0.3 check django2 version -> python -m django –version Create the Django project with…