Skip to main content

No project description provided

Project description

Script for VRA database for Costing

Developing

  1. Install docker-compose.
  2. Docker will run the postgres on port 5455 so, ensure the system has the port available
# run pytest testing 
./developer.sh pytest start

# run flake8 testing 
./developer.sh flake8 start 

# delete the testing environment
./developer.sh pytest stop

# delete the flake8 environment
./developer.sh flake8 stop

Package usage

  • To setup database
from ucampostgresvro import pre_setupconfig
from ucampostgresvro.DBA import DB
db_params = {
    "dbname": "vrapricing",
    "user": "postgres",
    "password": <1Password: vrapricingpostgres>,
    "host": "infra-db.srv.uis.cam.ac.uk", 
    "port": "5432",
    "sslmode": "require",
    "sslrootcert": "./ca.crt",  # path to your client certificate
}
db = DB(db_params)
pre_setupconfig(db_params)
  • To perform CRUD operation
from ucampostgresvro.DBA import DB
db_params = {
    "dbname": "vrapricing",
    "user": "postgres",
    "password": <1Password: vrapricingpostgres>,
    "host": "infra-db.srv.uis.cam.ac.uk", 
    "port": "5432",
    "sslmode": "require",
    "sslrootcert": "./ca.crt",  # path to your client certificate
}
db = DB(db_params)

# CRUD on user DB./

# create user
db.insert_vrauser("ll220", "Ling-Yan Lau")

# read user
print(db.get_vrauser())

# update user
db.update_vrauser("ll220", "bda20", 'Ben Argyle')

# delete user
db.remove_vrauser('bda20')

# create vra deploymentid 
db.insert_deployment_id("1231ee112ad11212")

# read vra deployment id
print(db.get_deployment_id("1231a"))

# update vra deployment id
db.update_deployment_id("1231ee112ad1", "1231a")

# delete vra deployment id
db.remove_deployment_id('1231a')

# create project 
db.insert_project("0001",1,100.0)

# read project 
print(db.get_project())

# update project 
db.update_project("0001", "0002", 4, 200)

# delete project
# db.remove_project("0002")

# create grant 
db.insert_grant("0001",1,100.0)

# read grant
print(db.get_grant())

# update grant 
db.update_grant("0001", "0002", 4, 200)

# delete grant
db.remove_grant("0002")

# create costing 
db.insert_costing(2, "Initial Resource", project_id=4, grant_id=None)

# read costing 
print(db.get_costing())

# update costing 
db.update_costing(2, "Duration Expansion", old_grant_id=4, old_project_id=None, grant_id=4, project_id=None)

# delete costing 
db.remove_costing(2, "Duration Expansion", 4, None)

# to close db connection
db.closedb()

Design

DB Design

- VRAUSER table

vrapricing=# \d vrauser;
                                    Table "public.vrauser"
 Column |          Type          | Collation | Nullable |               Default
--------+------------------------+-----------+----------+-------------------------------------
 id     | integer                |           | not null | nextval('vrauser_id_seq'::regclass)
 crsid  | character varying(255) |           |          |
 name   | character varying(255) |           |          |
Indexes:
    "vrauser_pkey" PRIMARY KEY, btree (id)
    "vrauser_crsid_key" UNIQUE CONSTRAINT, btree (crsid)
Referenced by:
    TABLE "purchaseorder" CONSTRAINT "purchaseorder_paid_by_fkey" FOREIGN KEY (paid_by) REFERENCES vrauser(id)
    TABLE "grant" CONSTRAINT "grant_paid_by_fkey" FOREIGN KEY (paid_by) REFERENCES vrauser(id)

- VRA Deployment ID tabel

vrapricing=# \d deploymentid;
                                      Table "public.deploymentid"
    Column    |         Type          | Collation | Nullable |                 Default
--------------+-----------------------+-----------+----------+------------------------------------------
 id           | integer               |           | not null | nextval('deploymentid_id_seq'::regclass)
 deploymentid | character varying(50) |           |          |
Indexes:
    "deploymentid_pkey" PRIMARY KEY, btree (id)
    "deploymentid_deploymentid_key" UNIQUE CONSTRAINT, btree (deploymentid)
Referenced by:
    TABLE "costing" CONSTRAINT "costing_deployment_id_fkey" FOREIGN KEY (deployment_id) REFERENCES deploymentid(id)

- project table

vrapricing=# \d projects;
                                        Table "public.projects"
     Column     |          Type          | Collation | Nullable |               Default
----------------+------------------------+-----------+----------+--------------------------------------
 id             | integer                |           | not null | nextval('projects_id_seq'::regclass)
 project_number | character varying(255) |           |          |
 paid_by        | integer                |           |          |
 amount         | double precision       |           | not null |
Indexes:
    "projects_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
    "projects_paid_by_fkey" FOREIGN KEY (paid_by) REFERENCES vrauser(id)
Referenced by:
    TABLE "costing" CONSTRAINT "costing_project_id_fkey" FOREIGN KEY (project_id) REFERENCES projects(id)

- grants table

vrapricing=# \d grant;
                                        Table "public.grant"
     Column     |          Type          | Collation | Nullable |               Default
----------------+------------------------+-----------+----------+--------------------------------------
 id             | integer                |           | not null | nextval('grant_id_seq'::regclass)
 voucher_number | character varying(255) |           |          |
 paid_by        | integer                |           |          |
 amount         | double precision       |           | not null |
Indexes:
    "grant_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
    "grant_paid_by_fkey" FOREIGN KEY (paid_by) REFERENCES vrauser(id)
Referenced by:
    TABLE "costing" CONSTRAINT "costing_voucher_id_fkey" FOREIGN KEY (voucher_id) REFERENCES grant(id)

- Costing table

vrapricing=# \d costing;
                                       Table "public.costing"
    Column     |          Type          | Collation | Nullable |               Default
---------------+------------------------+-----------+----------+-------------------------------------
 id            | integer                |           | not null | nextval('costing_id_seq'::regclass)
 deployment_id | integer                |           |          |
 type          | character varying(100) |           |          |
 po_number_id  | integer                |           |          |
 voucher_id    | integer                |           |          |
Indexes:
    "costing_pkey" PRIMARY KEY, btree (id)
Check constraints:
    "costing_type_check" CHECK (type::text = ANY (ARRAY['Resource Expansion'::character varying, 'Duration Expansion'::character varying, 'Initial Resource'::character varying]::text[]))
Foreign-key constraints:
    "costing_deployment_id_fkey" FOREIGN KEY (deployment_id) REFERENCES deploymentid(id)
    "costing_po_number_id_fkey" FOREIGN KEY (po_number_id) REFERENCES purchaseorder(id)
    "costing_voucher_id_fkey" FOREIGN KEY (voucher_id) REFERENCES grant(id)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ucampostgresvro-0.1.1.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ucampostgresvro-0.1.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file ucampostgresvro-0.1.1.tar.gz.

File metadata

  • Download URL: ucampostgresvro-0.1.1.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.12 Linux/6.8.0-51-generic

File hashes

Hashes for ucampostgresvro-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4d0406fa9bbb9e28ac6f219dfb3f0fffdff406b317ff19fe388fb915652cd154
MD5 d7b0118ffb87306a035b227200f41b6d
BLAKE2b-256 028da71beea2c477e779dab03d3c8c117db04dc2ab55746794b3d3d142c74fb6

See more details on using hashes here.

File details

Details for the file ucampostgresvro-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ucampostgresvro-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.12 Linux/6.8.0-51-generic

File hashes

Hashes for ucampostgresvro-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a916aac066af23943a706c9afd0df8895b58c5d6ab1e013f263ede7a5f504287
MD5 4d702b174d1508ad2adede46e03feb99
BLAKE2b-256 e1b6d6df0899b90585f4ab034a07f408616bb00c61c37618b53691f9ecbe5cfa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page