0% found this document useful (0 votes)
5 views5 pages

Day 62 Data Base Handling

The document outlines a structured overview of Python programming, covering core concepts, object-oriented programming, and advanced topics such as exception handling and multithreading. It also includes a practical demonstration of MySQL commands, showcasing database operations like creating, updating, and deleting records. Additionally, there are code snippets illustrating how to interact with a MySQL database using Python's MySQLdb module.

Uploaded by

prustysaurav604
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Day 62 Data Base Handling

The document outlines a structured overview of Python programming, covering core concepts, object-oriented programming, and advanced topics such as exception handling and multithreading. It also includes a practical demonstration of MySQL commands, showcasing database operations like creating, updating, and deleting records. Additionally, there are code snippets illustrating how to interact with a MySQL database using Python's MySQLdb module.

Uploaded by

prustysaurav604
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

core python

~~~~~~~~~~~~~
introduction
operators
data types
memory management
control structure and control stmt
function
module and package
command line argument
file handling

OOPs Using Python


~~~~~~~~~~~~~~~~~~
class and object
data member
method
constructor
destructor and garbage collector
operator overloading
relation
inheritance
polymorphism
abstract method and abstract class
access specifiers

ADV Python
~~~~~~~~~~~~~~
exception handling 3
multithreading 2
data base handling 1
gui 1
etc . . .

=============================================================

[seeree@localhost demo]$ mysql


ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (111)
[seeree@localhost demo]$
[seeree@localhost demo]$
[seeree@localhost demo]$ /etc/init.d/mysqld start
touch: cannot touch `/var/log/mysqld.log': Permission denied
chown: changing ownership of `/var/log/mysqld.log': Operation not permitted
chmod: changing permissions of `/var/log/mysqld.log': Operation not permitted
chown: changing ownership of `/var/lib/mysql': Operation not permitted
chmod: changing permissions of `/var/lib/mysql': Operation not permitted

[seeree@localhost demo]$ su
Password:
[root@localhost demo]# /etc/init.d/mysqld start
Starting MySQL: [ OK ]
[root@localhost demo]# /etc/init.d/mysqld stop
Stopping MySQL: [ OK ]
[root@localhost demo]# /etc/init.d/mysqld start
Starting MySQL: [ OK ]
[root@localhost demo]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
mysql> show databases ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| PROJECT |
| Summer |
| batch05 |
| demo |
| mysql |
| project |
| seeree |
| test |
+--------------------+
9 rows in set (0.46 sec)

mysql> use seeree ;


Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables ;
+------------------+
| Tables_in_seeree |
+------------------+
| student |
+------------------+
1 row in set (0.00 sec)

mysql> select * from student ;


+---------+--------+
| name | batch |
+---------+--------+
| sita | java |
| rama | python |
| hanuman | python |
+---------+--------+
3 rows in set (0.01 sec)

mysql> describe student ;


+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| name | varchar(30) | YES | | NULL | |
| batch | varchar(20) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.01 sec)

mysql>
mysql>
mysql>
mysql> select * from student ;
+---------+--------+
| name | batch |
+---------+--------+
| sita | java |
| rama | python |
| hanuman | python |
+---------+--------+
3 rows in set (0.00 sec)

mysql> insert into student ( name , batch ) values ( "sunil" , "c" ) ;


Query OK, 1 row affected (0.00 sec)

mysql> select * from student ;


+---------+--------+
| name | batch |
+---------+--------+
| sita | java |
| rama | python |
| hanuman | python |
| sunil | c |
+---------+--------+
4 rows in set (0.00 sec)

mysql> update table student set batch = 'python' where name = 'sunil' ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'table
student set batch = 'python' where name = 'sunil'' at line 1
mysql> update student set batch = 'python' where name = 'sunil' ;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from student ;


+---------+--------+
| name | batch |
+---------+--------+
| sita | java |
| rama | python |
| hanuman | python |
| sunil | python |
+---------+--------+
4 rows in set (0.00 sec)

mysql> delete table student where name = 'sunil' ;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'table
student where name = 'sunil'' at line 1
mysql> delete student where name = 'sunil' ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'where
name = 'sunil'' at line 1
mysql> delete from student where name = 'sunil' ;
Query OK, 1 row affected (0.00 sec)

mysql> select * from student ;


+---------+--------+
| name | batch |
+---------+--------+
| sita | java |
| rama | python |
| hanuman | python |
+---------+--------+
3 rows in set (0.00 sec)

mysql>

========================================================================
from MySQLdb import connect

bridge = connect ( db = "seeree" , user = "" )

bike = bridge . cursor ()

sqlStmt = """INSERT INTO student ( name , batch ) VALUES ( "shakti" , "java") ; """

bike . execute ( sqlStmt )

bike . close ()

bridge . close ()

=======================================================================
from MySQLdb import connect

bridge = connect ( db = "seeree" , user = "" )

bike = bridge . cursor ()

sqlStmt = """UPDATE student set batch = 'c++' where name = 'shakti' ; """

bike . execute ( sqlStmt )

bike . close ()

bridge . close ()

==================================================================================

from time import sleep


from MySQLdb import connect

bridge = connect ( db = "seeree" , user = "" )

bike = bridge . cursor ()

sqlStmt = """select * from student; """

bike . execute ( sqlStmt ) # load

records = bike . fetchall () # unload

print ( records )

for name , batch in records :


print ( name , batch )
sleep (1)

bike . close ()
bridge . close ()

============================================================

You might also like