Day 62 Data Base Handling
Day 62 Data Base Handling
~~~~~~~~~~~~~
introduction
operators
data types
memory management
control structure and control stmt
function
module and package
command line argument
file handling
ADV Python
~~~~~~~~~~~~~~
exception handling 3
multithreading 2
data base handling 1
gui 1
etc . . .
=============================================================
[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)
Database changed
mysql> show tables ;
+------------------+
| Tables_in_seeree |
+------------------+
| student |
+------------------+
1 row in set (0.00 sec)
mysql>
mysql>
mysql>
mysql> select * from student ;
+---------+--------+
| name | batch |
+---------+--------+
| sita | java |
| rama | python |
| hanuman | python |
+---------+--------+
3 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>
========================================================================
from MySQLdb import connect
sqlStmt = """INSERT INTO student ( name , batch ) VALUES ( "shakti" , "java") ; """
bike . close ()
bridge . close ()
=======================================================================
from MySQLdb import connect
sqlStmt = """UPDATE student set batch = 'c++' where name = 'shakti' ; """
bike . close ()
bridge . close ()
==================================================================================
print ( records )
bike . close ()
bridge . close ()
============================================================