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)
19 views
Database Connectivity
Uploaded by
raosahabsahab69
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save database connectivity For Later
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)
19 views
Database Connectivity
Uploaded by
raosahabsahab69
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save database connectivity For Later
Carousel Previous
Carousel Next
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
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6127)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brene Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (932)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8215)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2923)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4972)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Tóibín
3.5/5 (2061)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1987)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2641)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2543)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
Numpy
PDF
No ratings yet
Numpy
6 pages
2nd Sem
PDF
No ratings yet
2nd Sem
1 page
Oops
PDF
No ratings yet
Oops
3 pages
Practice
PDF
No ratings yet
Practice
2 pages
For
PDF
No ratings yet
For
6 pages
Def
PDF
No ratings yet
Def
5 pages
Fun
PDF
No ratings yet
Fun
4 pages
Assignment
PDF
No ratings yet
Assignment
8 pages
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Principles: Life and Work
From Everand
Principles: Life and Work
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Steve Jobs
From Everand
Steve Jobs
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Yes Please
From Everand
Yes Please
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
The Outsider: A Novel
From Everand
The Outsider: A Novel
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
John Adams
From Everand
John Adams
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
Numpy
PDF
Numpy
2nd Sem
PDF
2nd Sem
Oops
PDF
Oops
Practice
PDF
Practice
For
PDF
For
Def
PDF
Def
Fun
PDF
Fun
Assignment
PDF
Assignment
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
Little Women
From Everand
Little Women
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel