Compare commits

...

1 Commits

Author SHA1 Message Date
Ankur Malik
4c3aa40a58 Add db_push_uprova branch contents
All checks were successful
Build and Push Docker Image / setup (push) Successful in 4s
Build and Push Docker Image / build_and_push (push) Successful in 38s
2025-11-26 12:04:04 -05:00
6 changed files with 157 additions and 11 deletions

View File

@ -8,7 +8,8 @@ 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 +1,42 @@
**Hello world!!!**
# 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);
```

View File

@ -1,6 +1,14 @@
[
{
"namespace": "",
"connectionId": ""
}
]
{
"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"
}
]

View File

@ -1 +1,40 @@
Select * from dummy_table limit 10;
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;

View File

@ -1 +1,45 @@
{}
{
"$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 +1,14 @@
{}
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"properties": {
"result": {
"type": ["string", "null"]
},
"error": {
"type": ["string", "null"]
}
},
"required": []
}