top of page

Execute PostgreSQL Query Using Jupyter Notebook | SQL In Statistics

realcode4you

Configure PostgreSQL With Jupyter Notebook


First need to install:

#!pip install sqlalchemy==1.3.9
#!pip install ibm_db_sa
!pip install ipython-sql

Now installing psycopg2

!pip install psycopg2-binary

Adding Postgresql, Username , password and database

#%load_ext sql
%sql postgresql://username:Password@localhost/databasename

Now it connect with PostgreSQL.


Make a connection:

import psycopg2 as pg
import pandas.io.sql as psql
conn = pg.connect(database="nav**",user="postgres", password="Naveen@***")

Test the Query

%sql SELECT * FROM table1;

Output:

 * postgresql://postgres:***@localhost/naveen
2 rows affected.




Query1:

List the average length of the colums in the database.


%sql SELECT length(name) AS "Length" FROM table1; 

Output:

* postgresql://postgres:***@localhost/naveen 2 rows affected.

Out[52]: length

1

1



Practice Queries(DVD Rental)


Query 1:

List the Film Title (film.title) and language (language.name) for each film in the database


Query 2:

List each film and the name of actors in that film, in order of film title then actor last name.


Query 3:

List each customer's id, name, postal code, and phone number.


Query 4:

List the film title with the customer name who rented the film, in order of film title


Query 5:

List a unique (DISTINCT) set of film titles with the staff last name who rented out the film.



If you need to looking Data Analytics Assignment Help Using SQL Machine Learning then contact us or send your requirement details at:


realcode4you@gmail.com


And get instant help with an affordable price.


Commentaires


REALCODE4YOU

Realcode4you is the one of the best website where you can get all computer science and mathematics related help, we are offering python project help, java project help, Machine learning project help, and other programming language help i.e., C, C++, Data Structure, PHP, ReactJs, NodeJs, React Native and also providing all databases related help.

Hire Us to get Instant help from realcode4you expert with an affordable price.

USEFUL LINKS

Discount

ADDRESS

Noida, Sector 63, India 201301

Follows Us!

  • Facebook
  • Twitter
  • Instagram
  • LinkedIn

OUR CLIENTS BELONGS TO

  • india
  • australia
  • canada
  • hong-kong
  • ireland
  • jordan
  • malaysia
  • new-zealand
  • oman
  • qatar
  • saudi-arabia
  • singapore
  • south-africa
  • uae
  • uk
  • usa

© 2023 IT Services provided by Realcode4you.com

bottom of page