Compare commits

..

No commits in common. "db-push-uprova" and "main" have entirely different histories.

6 changed files with 11 additions and 157 deletions

View File

@ -8,8 +8,7 @@ WORKDIR /app
# Copy user-specific files (block.py, schemas, requirements)
COPY . .
RUN ls ./
RUN ls ./
# Set CMD to execute the symbolic link, making it look like block.py is the entry
CMD ["python", "/app/block_wrapper.py"]
CMD ["python", "/app/block_wrapper.py"]

View File

@ -1,42 +1 @@
# db_push_uprova
Block for upserting uprova application data into the `public.uprova` table in the `staging` database.
The table stores uprova-specific attributes keyed by `application_key`. The block uses a parameterised
`INSERT ... ON CONFLICT ... DO UPDATE` statement defined in `main.sql` to upsert records.
## Table DDL
The `public.uprova` table can be created with the following SQL, following the style of
`k8s/mlgraph-db/init-configmap.yaml`:
```sql
-- Connect to postgres database as superuser
\c postgres;
-- Create databases
CREATE DATABASE staging;
-- Grant privileges
GRANT ALL PRIVILEGES ON DATABASE staging TO cpflowxuser;
-- Connect to staging database and create uprova table
\connect staging;
CREATE TABLE IF NOT EXISTS uprova (
application_key TEXT PRIMARY KEY,
application_timestamp TIMESTAMP NOT NULL,
educationlevel TEXT NULL,
employmentstatus TEXT NULL,
lengthatbank TEXT NULL,
lengthatjob NUMERIC NULL,
ownhome BOOLEAN NULL,
payfrequency TEXT NULL,
monthsatresidence NUMERIC NULL,
state TEXT NULL,
zip TEXT NULL
);
CREATE INDEX IF NOT EXISTS idx_uprova_application_key ON uprova (application_key);
CREATE INDEX IF NOT EXISTS idx_uprova_application_timestamp ON uprova (application_timestamp);
```
**Hello world!!!**

View File

@ -1,14 +1,6 @@
[
{
"namespace": "staging",
"connectionId": "56be80f8-7139-466f-b883-e4a695812d52"
},
{
"namespace": "production",
"connectionId": "cf2344a8-28d3-4b38-9456-ba9e5c347bf5"
},
{
"namespace": "production-beta",
"connectionId": "cf2344a8-28d3-4b38-9456-ba9e5c347bf5"
}
]
{
"namespace": "",
"connectionId": ""
}
]

View File

@ -1,40 +1 @@
INSERT INTO public.uprova (
application_key,
application_timestamp,
educationlevel,
employmentstatus,
lengthatbank,
lengthatjob,
ownhome,
payfrequency,
monthsatresidence,
state,
zip
)
VALUES (
$application_key,
$application_timestamp,
$educationlevel,
$employmentstatus,
$lengthatbank,
$lengthatjob,
$ownhome,
$payfrequency,
$monthsatresidence,
$state,
$zip
)
ON CONFLICT (application_key)
DO UPDATE
SET
application_timestamp = EXCLUDED.application_timestamp,
educationlevel = EXCLUDED.educationlevel,
employmentstatus = EXCLUDED.employmentstatus,
lengthatbank = EXCLUDED.lengthatbank,
lengthatjob = EXCLUDED.lengthatjob,
ownhome = EXCLUDED.ownhome,
payfrequency = EXCLUDED.payfrequency,
monthsatresidence = EXCLUDED.monthsatresidence,
state = EXCLUDED.state,
zip = EXCLUDED.zip;
Select * from dummy_table limit 10;

View File

@ -1,45 +1 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"properties": {
"application_key": {
"type": "string"
},
"application_timestamp": {
"type": "string",
"format": "date-time"
},
"educationlevel": {
"type": ["string", "null"]
},
"employmentstatus": {
"type": ["string", "null"]
},
"lengthatbank": {
"type": ["string", "null"]
},
"lengthatjob": {
"type": ["number", "null"]
},
"ownhome": {
"type": ["boolean", "null"]
},
"payfrequency": {
"type": ["string", "null"]
},
"monthsatresidence": {
"type": ["number", "null"]
},
"state": {
"type": ["string", "null"]
},
"zip": {
"type": ["string", "null"]
}
},
"required": [
"application_key",
"application_timestamp"
]
}
{}

View File

@ -1,14 +1 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"properties": {
"result": {
"type": ["string", "null"]
},
"error": {
"type": ["string", "null"]
}
},
"required": []
}
{}