openGauss Is based on PostgreSQL9.2 Version developed , Basically includes PostgreSQL9.4 Function of . Therefore, connection can be adopted postgresql Connected in different ways openGauss database .

<> Create a new project

Open the terminal in any folder and enter the following command to create a new one django project
django-admin startproject connect_db
among “connect_db” Is the project name

The above files will be generated after creation

<> Configure connection database file

Under the folder with the same name under the project folder setting.py Modify configuration in

modify setting.py Medium DATABASE to configure
DATABASES = { 'default': { # 'ENGINE': 'django.db.backends.sqlite3', 'ENGINE':
'django.db.backends.postgresql_psycopg2', 'NAME': 'postgres', # Database name 'USER':
'andy', # user name 'PASSWORD': 'test123', # password 'HOST': '192.168.56.101',# virtual machine ip 'PORT':
26000 #openGauss Port of data port } }

virtual machine IP query
Input at the virtual machine terminal ifconfig

<> Test connection

Open the terminal execution in the project folder python manage.py runserver

If no error is reported, the connection is successful
Open browser to view

Technology