In: Computer Science
my question is in python.
My question is how to add post users to post gres in python
HOW TO ADD POST USERS TO POST GRES IN PYTHON:
The users of Postgres, to add the new users to the database, send that new user confirmation email, receive a response from their link and set a flag in the PostgreSQL database that the user is confirmed. It is compared with the hash in PostgreSQL database. Using Python and PostgreSQL the final updating of the database is send back to the login screen.
import psycopg2
from psycopg2 import sql
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
con = psycopg2.connect(dbname='postgres',
user=self.user_name, host='',
password=self.password)
con.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cur = con.cursor()
# Use the psycopg2.sql module instead of string concatenation
# in order to avoid sql injection attacs.
cur.execute(sql.SQL("CREATE DATABASE ()").format(
sql.Identifier(self.db_name))
)