Rough ideas

 


Selecting a particular item column wise from mysql database:-

#below syntax will query value from column named "id"

SELECT DISTINCT id FROM menu; (; is a delimiter to separate the syntax)

Where is used to declare a condition in mysql to narrow the result of the search

mysql> SELECT * FROM menu WHERE id='5';

Allows user to sort table by column (name)

SELECT * FROM menu GROUP BY name;

To show tables in database

SHOW TABLES in <database name>;

To interact with Database Python follows below mechanism

1. import mysql

2. import connector from mysql or map to a variable in python

3. make connection with database

4.make a cursor 

5.then execute commands

6.close the database

We will see that we are following this hierarchy through out our examples..

First import python with following command

from mysql import connector as con # I have imported 'connector' function from mysql and map to con


Comments

Popular posts from this blog

Python with mysql codes