Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
25 views
6 pages
Database Connectivity
Uploaded by
raosahabsahab69
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save database connectivity For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
25 views
6 pages
Database Connectivity
Uploaded by
raosahabsahab69
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save database connectivity For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 6
Search
Fullscreen
9125123, 9:40 AM In [2]: In [4]: localhost 8888inotebooks/Untiled225.pynb ke LUntilea228 - Jupyter Notebook M pip install mysql-connector-python Requirement already satisfied: mysql-connector-python in c:\users\pc\anac onda3\1ib\site-packages (8.0.33) Requirement already satisfied: protobuf<=3.20.3,>=3.11.0 in c:\users\pc\a naconda3\1ib\site-packages (from mysql-connector-python) (3.20.3) Note: you may need to restart the kernel to use updated packages. M mport mysql.connector as c on=c, connect (host="1ocalhost" use! # con.is_connected(): print("success") Ase: print("issues") root", passwd="server",database="tanisha 5 name=pythond 189125123, 9:40 AM Umitted226 - Jupyter Notebook In [6]: M #database created mydb=c. connect (host="1ocalhost" user: cur=mydb..cursor() cur.execute("create database vikrant") print("database created”) oot" ,passwd=" server") localhost 8888/notebooks/Untiled226 ipynbkerel_name=python39125123, 9:40 AM localhost 8888inotebooks/Untiled225.pynb ke Umitted226 - Jupyter Notebook mysQLinterfacetrror Traceback (most recent call las t) File ~\anaconda3\1ib\site-packages\nysql\connector\connection_cext.. py:61 1, in CMySQLConnection.cmd_query(self, query, raw, buffered, raw_as_strin 8) 616 query = query.encode(“utf-8") --> 611 —_self._emysql.query( 612 query, 613 raw-raw, 614 butfered-buffered, 615 raw_as_string=raw_as_string, 616 query_attrs=self._query_attrs, 617) 618 except MySQLInterfacerror as err: MysQLInterfaceError: Can't create database ‘vikrant'; database exists The above exception was the direct cause of the following exception: DatabaseError Traceback (most recent call las %) Cell In[6], line 3 connect (host="Localhos' server") > 3 cur.execute(* 4 print (“database created") File ~\anaconda3\1ib\site-packages\mysql\connector\cursor_cext .py:330, in CMysQLCursor.execute(self, operation, params, multi) 325 raise ProgranmingError( 326 “Not all parameters were used in the SQL statemen 327 ) 329 try: --> 338 result = self._cnx.cmd_query( 331 stmt, 332 raw=self._raw, 333 buffered=self._buffered, 334 raw_as_string-self._raw_as_string, 335 ) 336 except MySQLInterfaceError as err: 337 raise get_mysql_exception( 338 msg-err.msg, errno-err.errno, sqlstate-err.sqlstate 339) from err File ~\anaconda3\1ib\site-packages\mysql\connector\connection_cext. py:61 9, in CMysQLConnection.end_query(self, query, raw, buffered, raw_as_strin 8) 611 _seLf._emysql.query( 612 query, 613 raw=raw, query_attrs-self._query_attrs, oy) 618 except MySQLInterfaceError as err: 5 name=pythond a69125123, 9:40 AM In [7]: In [9]: In [10]: localhost 8888inotebooks/Untiled225.pynb ke y W w LUntilea228 - Jupyter Notebook --> 619 raise get_mysql_exception( 620 err.errno, msg-err.msg, sqlstate-err. sqlstate 621+) from err 622 except AttributeError as err: 623. addr = ( 624 self._unix_socket if self._unix_socket else f"{self._hos t):{self._port}" 625) DatabaseError: 1087 (HY@00): Can't create database ‘vikrant'; database ex ists #table created mydb=c. connect (host=" localhost" ,user="root" ,passwd="server",database="Vikri cursmydb.cursor() e="create table employee(empid int,emp_name varchar(2@),salary int)" cur.execute(e) print("Table created successfully") Table created successfully #insert single data into table nydb=c. connect (host=" localhost" , user="root" , passwd=" server", database="vikri iydb. cursor() insert into employee(empid,emp_name,salary)values(%s,%s,%s)" cur.execute(e,b1) mydb. commit () print("data inserted successfully") data inserted successfully #insert multiple data into table mydb=c. connect (host="localhost™, user: cur=mydb. cursor() e="insert into employee(empid,emp_name,salary)values(%s,%s,%s)" b1=(102, "Pawan" 66000), (103, "Rahul" 87000), (124, "Pankaj", 75000) curexecutenany(e,b1) nydb. conmit () print("Multiple data inserted successfully") ‘oot ,passwd="server" ,database="vikri Multiple data inserted successfully 5 name=pythond 469125123, 9:40 AM Tn [11]: in [22]: In [14]: out [24]: In [15]: Intl: W localhost 8888inotebooks/Untiled225.pynb ke LUntilea228 - Jupyter Notebook fupdated data mydb=c. connect (host=" localhost" user: cur=mydb.cursor() e="update employee set salar cur.execute(e) mydb. commit () print("data updated successfully") ‘oot" ,passwd="server" , database (22200 where empid=162" data updated successfully adeLeted data mydb=c. connect (host="localhost" ,user="root", passwd: cursmydb.cursor() e="delete from employee where empi cur.execute(e) mmydb . commit () print("data deleted successfully") i=" server" ,database="vikri data deleted successfully #fetch data mydb=c. connect (host=" localhost" ,user="root", passwd="server",database="vikré db. cursor() select * from employee" cur.execute(data) result=cur. fetchall() result dprint("******EMpLoyee data *#+*") [(2@2, ‘Pawan’, 100000), (103, ‘Rahul’, 87000), (104, ‘Pankaj’, 75000)] ‘fetch data nydb=c. connect (host=" localhost" , user="root" , passd=" server", database="vikri cursmydb.cursor() data="select * from employee" cur.execute(data) result=cur. fetchall() for rec in resul print (rec) (102, "Pawan', 100000) (a@3, ‘Rahul’, 87200) (104, "Pankaj', 75000) 5 name=pythond 569125123, 9:40 AM LUntilea228 - Jupyter Notebook localhost 8888/notebooks/Untiled226 ipynbkerel_name=python3 6s
You might also like
Interfacing Python To Mysql
PDF
No ratings yet
Interfacing Python To Mysql
20 pages
Arp MGMT
PDF
No ratings yet
Arp MGMT
17 pages
Mysql Queries For 2 Tables Practical
PDF
No ratings yet
Mysql Queries For 2 Tables Practical
4 pages
ML SQL Programs
PDF
No ratings yet
ML SQL Programs
9 pages
Prog 19 and 20 CL 12 Record
PDF
No ratings yet
Prog 19 and 20 CL 12 Record
8 pages
Tuple
PDF
No ratings yet
Tuple
13 pages
Acknowledgement: Mrs. BEENA PRASHANT For Her Constant Encouragement, Guidance
PDF
No ratings yet
Acknowledgement: Mrs. BEENA PRASHANT For Her Constant Encouragement, Guidance
52 pages
Python Tips
PDF
No ratings yet
Python Tips
36 pages
DB Connectivity
PDF
No ratings yet
DB Connectivity
67 pages
Dbms Exp 9
PDF
No ratings yet
Dbms Exp 9
5 pages
All Command For MySQL Connector
PDF
No ratings yet
All Command For MySQL Connector
6 pages
Account Periodic
PDF
No ratings yet
Account Periodic
23 pages
PROGRAMMS 11 Split Merge
PDF
No ratings yet
PROGRAMMS 11 Split Merge
20 pages
p16 Creating Table Using Mysql Connectivity
PDF
No ratings yet
p16 Creating Table Using Mysql Connectivity
7 pages
Advanced Python Programming - Lesson No.005
PDF
No ratings yet
Advanced Python Programming - Lesson No.005
13 pages
Python+Mysql 7
PDF
No ratings yet
Python+Mysql 7
11 pages
Exp 30
PDF
No ratings yet
Exp 30
5 pages
DBMS Exp11
PDF
No ratings yet
DBMS Exp11
5 pages
Emp Project
PDF
No ratings yet
Emp Project
18 pages
Data Base Connectvity in Python
PDF
No ratings yet
Data Base Connectvity in Python
19 pages
قواعد عملي 4
PDF
No ratings yet
قواعد عملي 4
4 pages
SQL & Python - Jupyter Notebook
PDF
No ratings yet
SQL & Python - Jupyter Notebook
7 pages
Python Connecting To Mysql Database
PDF
No ratings yet
Python Connecting To Mysql Database
6 pages
LINUX2
PDF
No ratings yet
LINUX2
7 pages
Rohit Ex 8 Final
PDF
No ratings yet
Rohit Ex 8 Final
5 pages
Getting Started With MySQL and Python PDF
PDF
No ratings yet
Getting Started With MySQL and Python PDF
12 pages
L9 Python and MySQL DB Connection
PDF
No ratings yet
L9 Python and MySQL DB Connection
6 pages
Python Interface - With Mysql Connector
PDF
No ratings yet
Python Interface - With Mysql Connector
15 pages
Exp 11
PDF
No ratings yet
Exp 11
3 pages
Day 62 Data Base Handling
PDF
No ratings yet
Day 62 Data Base Handling
5 pages
Python Database Connectivity
PDF
No ratings yet
Python Database Connectivity
24 pages
The Python Database API
PDF
No ratings yet
The Python Database API
9 pages
CH 8,9,10 SQL
PDF
No ratings yet
CH 8,9,10 SQL
62 pages
Project No 1 - 2
PDF
No ratings yet
Project No 1 - 2
23 pages
LabManual (14 17)
PDF
No ratings yet
LabManual (14 17)
10 pages
Python MYSQL
PDF
No ratings yet
Python MYSQL
29 pages
Python & MySQL
PDF
No ratings yet
Python & MySQL
17 pages
Python Mysql Tutorials
PDF
No ratings yet
Python Mysql Tutorials
5 pages
Unit 5 Python
PDF
No ratings yet
Unit 5 Python
13 pages
MySQL Interface Python
PDF
No ratings yet
MySQL Interface Python
8 pages
Database Programs
PDF
No ratings yet
Database Programs
5 pages
Interface Python With MySQL1
PDF
No ratings yet
Interface Python With MySQL1
12 pages
Inteface Python With Mysql
PDF
No ratings yet
Inteface Python With Mysql
13 pages
12 CS QB Ch. 4
PDF
No ratings yet
12 CS QB Ch. 4
8 pages
Interface Python With SQL
PDF
No ratings yet
Interface Python With SQL
17 pages
Chapter 14 Interface Python With Mysql
PDF
No ratings yet
Chapter 14 Interface Python With Mysql
10 pages
Python + MySql Connectivity
PDF
No ratings yet
Python + MySql Connectivity
4 pages
Python Database
PDF
No ratings yet
Python Database
3 pages
Xii CS Worksheet
PDF
No ratings yet
Xii CS Worksheet
3 pages
PDBC
PDF
No ratings yet
PDBC
4 pages
Exp10 Python
PDF
No ratings yet
Exp10 Python
10 pages
Connecting Python With SQL Database
PDF
No ratings yet
Connecting Python With SQL Database
21 pages
Pyton Book
PDF
No ratings yet
Pyton Book
15 pages
Python Database Connectivity
PDF
No ratings yet
Python Database Connectivity
12 pages
MySQL Connectivity - Nandini Das
PDF
No ratings yet
MySQL Connectivity - Nandini Das
27 pages
Interfaceworksheet 24
PDF
No ratings yet
Interfaceworksheet 24
13 pages
Python - Mysql Database Access: Gadfly MSQL Mysql Postgresql Microsoft SQL Server 2000 Informix Interbase Oracle Sybase
PDF
No ratings yet
Python - Mysql Database Access: Gadfly MSQL Mysql Postgresql Microsoft SQL Server 2000 Informix Interbase Oracle Sybase
10 pages
Python 3 - MySQL Database Access
PDF
No ratings yet
Python 3 - MySQL Database Access
10 pages
MySQL and Python Connectivity
PDF
No ratings yet
MySQL and Python Connectivity
5 pages
Assignment
PDF
No ratings yet
Assignment
8 pages
2nd Sem
PDF
No ratings yet
2nd Sem
1 page
Numpy
PDF
No ratings yet
Numpy
6 pages
Practice
PDF
No ratings yet
Practice
2 pages
Fun
PDF
No ratings yet
Fun
4 pages
Oops
PDF
No ratings yet
Oops
3 pages
Def
PDF
No ratings yet
Def
5 pages
For
PDF
No ratings yet
For
6 pages