PostgreSql
Monday, January 25, 2021 9:14 AM
Python postgresql
------------------
https://www.tutorialspoint.com/postgresql/postgresql_python.htm
PostgreSQL
-----------
1. PostgreSQL, also known as Postgres.
2. It is a free and open-source relational database management system
3. It has many features that safely store and scale the most
complicated data workloads.
postgresql installation steps notesv
-------------------------------------------------
https://medium.com/@9cv9official/creating-a-django-web-application-with-a-postgresql-database-on-windows-
c1eea38fe294
Installation steps
----------------------
1. link for downloading postgresql
-----------------------------------------------
https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
2. click on downloaded software
3. check the below mentioned softwares
1. PostgreSQL server
2. pgadmin 4
3. Commandline tools and click on next
4. Now it will ask for password
enter password
re-enter-password and press next
5. leave the default port number as it is
6. With the above steps PostgreSQL is installed successfully
psycopg2:
---------
1. in order to utilize postegresql we have to install below mentioned
python package
pip install psycopg2
2. psycopg2 is a database driver
3. psycopg2 sends SQL statements to the database.
Now Configuring postgresql with in the settings.py file of ur project
---------------------------------------------------------------------
1. Go to settings.py file
2. now after this scroll down to database section
Syntax:
-------
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'DataBasename',
'USER' : 'username',
'PASSWORD' : 'usernamepassword',
'HOST' : 'localhost' ,
'PORT' : 5432,
}
}
example:
----------
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'harshad',
'USER' : 'postgres',
'PASSWORD' : 'nikky786',
'HOST' : 'localhost' ,
'PORT' : 5432,
}
}
postgradesql installation steps notes
---------------------------------------
https://medium.com/@9cv9official/creating-a-django-web-application-with-a-postgresql-database-on-windows-
c1eea38fe294
syntaxes/symbols usage
------------------------------------------------------------------
1. create database databasename; creates a database
2. \c databasename; access to Database
3. \d,\dt displays the database tables relations
4. \l displays the databases of user
5. \l+ displays the databases of user with sizes
6. \? displays each and every symbols along
with usage
7. q helps end or come back
8. \du displays the list of users
9. \du+ displays the list of users along with
description
Syntaxes:
---------
1. For creating a database
create database databasename;
Procedure to access The data of Models:
---------------------------------------
1. first create a database
create database databasename;
2. For accessing the created database
\c databasename;
3. after accessing the data base, we cannot access the table details directly
by using the Model_names
4. So in-order to access the tables we need to to go with relations
5. syntax for accessing the list relations of the database
\dt;
6. Example:
-------------
List of relations
Schema | Name | Type | Owner
--------+----------------------------+-------+----------
public | app_access_records | table | postgres
public | app_topic | table | postgres
public | app_webpage | table | postgres
public | auth_group | table | postgres
public | auth_group_permissions | table | postgres
public | auth_permission | table | postgres
public | auth_user | table | postgres
public | auth_user_groups | table | postgres
public | auth_user_user_permissions | table | postgres
public | django_admin_log | table | postgres
public | django_content_type | table | postgres
public | django_migrations | table | postgres
public | django_session | table | postgres
(13 rows)
7. we have to access the Table information by using the Relation names
8. Syntax for accessing the info of models
select * from relation_name;
example:
----------
select * from app_topic;
procedure to create user by using pg admin:
-------------------------------------------
https://www.guru99.com/postgresql-create-alter-add-user.html#1
Installation steps
----------------------
1. link for downloading postgradesql
----------------------------------
https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
2. click on downloaded software
3. check the below mentioned softwares
1. PostgreSQL server
2. pgadmin 4
3. Commandline tools and click on next
4. Now it will ask for password
enter password
re-enter-password and press next
5. leave the default port number as it is
6. With the above steps PostgreSQL is installed successfully