From 51563e2dcd5fad3b9b0f64cb5168c3cfa71ea972 Mon Sep 17 00:00:00 2001 From: medina5 Date: Mon, 6 Oct 2025 22:08:23 +0200 Subject: [PATCH] graphe --- README.md | 2 +- compose.yaml | 13 +- data/graphe/clients.csv | 41 +++ data/graphe/comptes.csv | 77 ++++++ data/graphe/transactions.csv | 236 ++++++++++++++++++ .../9_json.sql | 9 +- .../1_import.sh | 2 +- 7 files changed, 371 insertions(+), 9 deletions(-) create mode 100644 data/graphe/clients.csv create mode 100644 data/graphe/comptes.csv create mode 100644 data/graphe/transactions.csv rename json/json.sql => docker-entrypoint-initdb.d/9_json.sql (79%) rename mongo-init/01-import.sh => mongodb-entrypoint-initdb.d/1_import.sh (77%) mode change 100644 => 100755 diff --git a/README.md b/README.md index e8449cf..eedf806 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### Construire l'image ```shell -docker build -t iut/pgsql:2025-11 . +docker build -t iut/pgsql:2025-12 . ``` ## Données diff --git a/compose.yaml b/compose.yaml index a2e2371..ef655ad 100644 --- a/compose.yaml +++ b/compose.yaml @@ -9,7 +9,7 @@ services: volumes: - database_data:/var/lib/postgresql:rw - ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:Z - - ./data:/tmp:Z + - ./data:/tmp:z ports: - 5432:5432 healthcheck: @@ -87,17 +87,21 @@ services: COUCHDB_USER: ${DB_ROOT_USER:-admin} COUCHDB_PASSWORD: ${DB_ROOT_PASSWORD:-!ChangeMe!} +# MongoDB +# +# https://www.mongodb.com/ mongodb: image: mongodb/mongodb-community-server:8.0-ubi8 volumes: - mongodb_configdb:/data/configdb - mongodb_data:/data/db - - ./mongo-init:/docker-entrypoint-initdb.d + - ./mongodb-entrypoint-initdb.d:/docker-entrypoint-initdb.d:Z + - ./data:/initdb.d:z ports: - "27017:27017" environment: - MONGO_INITDB_ROOT_USERNAME: ${DB_ROOT_USER:-admin} - MONGO_INITDB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-!ChangeMe!} + MONGODB_INITDB_ROOT_USERNAME: ${DB_ROOT_USER:-admin} + MONGODB_INITDB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-!ChangeMe!} # Redis # In-memory key-value database @@ -135,7 +139,6 @@ services: environment: NEO4J_AUTH: neo4j/${DB_ROOT_PASSWORD:-!ChangeMe!} - volumes: database_data: superset_home: diff --git a/data/graphe/clients.csv b/data/graphe/clients.csv new file mode 100644 index 0000000..2fefb9e --- /dev/null +++ b/data/graphe/clients.csv @@ -0,0 +1,41 @@ +client_id,nom,ville +C1,Client1,Nantes +C2,Client2,Paris +C3,Client3,Paris +C4,Client4,Nantes +C5,Client5,Marseille +C6,Client6,Lyon +C7,Client7,Lyon +C8,Client8,Lyon +C9,Client9,Nantes +C10,Client10,Paris +C11,Client11,Nantes +C12,Client12,Nantes +C13,Client13,Toulouse +C14,Client14,Paris +C15,Client15,Toulouse +C16,Client16,Lille +C17,Client17,Paris +C18,Client18,Paris +C19,Client19,Paris +C20,Client20,Lyon +C21,Client21,Lyon +C22,Client22,Toulouse +C23,Client23,Toulouse +C24,Client24,Paris +C25,Client25,Toulouse +C26,Client26,Lyon +C27,Client27,Nantes +C28,Client28,Nantes +C29,Client29,Nantes +C30,Client30,Toulouse +C31,Client31,Lille +C32,Client32,Lyon +C33,Client33,Lille +C34,Client34,Toulouse +C35,Client35,Marseille +C36,Client36,Bordeaux +C37,Client37,Bordeaux +C38,Client38,Paris +C39,Client39,Bordeaux +C40,Client40,Bordeaux diff --git a/data/graphe/comptes.csv b/data/graphe/comptes.csv new file mode 100644 index 0000000..c2a9bab --- /dev/null +++ b/data/graphe/comptes.csv @@ -0,0 +1,77 @@ +compte_id,solde,client_id,fraude +A1,7024,C1,true +A2,4652,C2,false +A3,2647,C2,false +A4,5614,C3,false +A5,1619,C4,false +A6,1684,C5,false +A7,5981,C5,false +A8,9991,C6,false +A9,4433,C6,false +A10,7627,C7,false +A11,2145,C8,false +A12,6301,C8,false +A13,1391,C8,false +A14,4903,C9,true +A15,6025,C9,false +A16,9559,C9,false +A17,1239,C10,false +A18,3833,C11,false +A19,1407,C12,false +A20,3914,C12,true +A21,6327,C13,true +A22,7528,C14,false +A23,6077,C14,true +A24,6165,C15,false +A25,3532,C16,false +A26,4474,C16,true +A27,1269,C17,false +A28,2903,C17,false +A29,8851,C17,false +A30,4110,C18,false +A31,2777,C18,false +A32,7673,C18,false +A33,4522,C19,false +A34,9225,C19,true +A35,5413,C20,false +A36,3852,C21,false +A37,5268,C22,false +A38,4486,C23,false +A39,1184,C23,true +A40,9392,C24,false +A41,5255,C25,false +A42,3583,C25,false +A43,8279,C25,false +A44,7617,C26,false +A45,2440,C26,false +A46,2387,C27,false +A47,4140,C27,false +A48,9297,C28,true +A49,8930,C28,false +A50,4404,C28,false +A51,9677,C29,false +A52,7119,C29,false +A53,9660,C29,false +A54,6030,C30,false +A55,3693,C30,false +A56,8448,C31,false +A57,1589,C32,false +A58,871,C32,false +A59,2604,C33,false +A60,2721,C34,false +A61,7016,C34,false +A62,9871,C34,false +A63,6404,C35,false +A64,9863,C36,false +A65,7768,C36,true +A66,4219,C37,false +A67,9164,C37,false +A68,288,C37,true +A69,1976,C38,false +A70,8897,C38,true +A71,4471,C38,false +A72,5673,C39,false +A73,1927,C39,false +A74,4908,C39,false +A75,2691,C40,false +A76,7533,C40,false diff --git a/data/graphe/transactions.csv b/data/graphe/transactions.csv new file mode 100644 index 0000000..5ac16d0 --- /dev/null +++ b/data/graphe/transactions.csv @@ -0,0 +1,236 @@ +from,to,montant,date +A42,A63,239,2024-01-05 +A47,A40,128,2024-03-02 +A31,A73,185,2024-01-21 +A63,A9,1100,2024-07-13 +A17,A61,348,2024-05-20 +A34,A68,876,2024-06-04 +A28,A70,1504,2024-07-12 +A26,A40,1385,2024-04-12 +A48,A57,934,2024-05-12 +A16,A32,141,2024-02-27 +A44,A3,1144,2024-05-30 +A30,A76,24,2024-02-26 +A10,A8,148,2024-02-28 +A5,A43,1062,2024-01-19 +A31,A36,1004,2024-06-20 +A28,A70,1491,2024-02-03 +A74,A61,1616,2024-03-03 +A61,A53,203,2024-02-18 +A13,A56,877,2024-03-31 +A53,A60,120,2024-07-05 +A13,A8,1501,2024-04-13 +A44,A14,402,2024-03-04 +A25,A69,297,2024-04-24 +A55,A24,957,2024-03-12 +A32,A10,1664,2024-04-23 +A71,A13,1345,2024-01-13 +A70,A2,1907,2024-01-24 +A31,A22,1004,2024-04-14 +A62,A28,1858,2024-04-12 +A8,A22,14,2024-04-07 +A50,A34,1617,2024-07-19 +A59,A37,1436,2024-04-18 +A72,A63,398,2024-02-09 +A38,A28,1196,2024-01-15 +A70,A8,652,2024-07-10 +A8,A7,986,2024-05-29 +A65,A68,126,2024-02-10 +A66,A11,150,2024-02-17 +A9,A31,255,2024-04-13 +A73,A32,1227,2024-05-28 +A6,A11,1356,2024-04-17 +A75,A73,657,2024-05-13 +A34,A27,1476,2024-06-20 +A41,A31,820,2024-03-08 +A17,A39,657,2024-04-27 +A10,A2,1282,2024-04-27 +A73,A13,1111,2024-01-19 +A28,A65,281,2024-03-08 +A45,A9,766,2024-03-03 +A37,A21,1717,2024-04-22 +A70,A39,1662,2024-06-05 +A68,A2,1683,2024-06-19 +A71,A39,222,2024-06-18 +A18,A34,1832,2024-01-30 +A14,A71,567,2024-02-09 +A37,A27,712,2024-07-02 +A27,A34,1010,2024-05-09 +A33,A7,1309,2024-01-24 +A55,A36,17,2024-01-12 +A43,A17,546,2024-06-12 +A21,A57,1455,2024-05-21 +A55,A72,239,2024-01-03 +A10,A20,83,2024-05-19 +A48,A75,313,2024-05-21 +A56,A17,641,2024-01-11 +A47,A6,440,2024-04-01 +A32,A14,1607,2024-03-31 +A72,A53,1544,2024-06-07 +A20,A31,1648,2024-02-11 +A23,A53,377,2024-01-07 +A43,A53,1779,2024-06-20 +A32,A35,1622,2024-02-10 +A14,A49,1768,2024-01-10 +A61,A29,1682,2024-02-21 +A59,A45,1690,2024-03-19 +A30,A29,1361,2024-01-07 +A25,A52,580,2024-03-25 +A9,A36,1323,2024-03-30 +A66,A52,1737,2024-06-22 +A69,A43,246,2024-01-08 +A34,A23,1981,2024-05-28 +A34,A5,1231,2024-01-28 +A56,A45,1620,2024-07-05 +A41,A56,1057,2024-06-04 +A15,A50,399,2024-05-27 +A33,A6,903,2024-06-30 +A1,A67,1416,2024-05-17 +A26,A47,153,2024-04-20 +A43,A41,1746,2024-06-18 +A16,A39,643,2024-05-09 +A53,A42,1437,2024-04-13 +A38,A71,402,2024-02-02 +A54,A49,1542,2024-06-22 +A23,A73,841,2024-03-18 +A71,A1,597,2024-03-18 +A27,A56,1252,2024-05-28 +A42,A60,915,2024-04-23 +A28,A66,1635,2024-05-01 +A22,A11,1065,2024-03-13 +A43,A12,491,2024-07-11 +A40,A29,311,2024-02-20 +A4,A6,983,2024-03-03 +A10,A59,1824,2024-04-16 +A74,A25,1436,2024-07-02 +A50,A64,509,2024-04-12 +A19,A1,1772,2024-07-11 +A14,A55,370,2024-02-26 +A67,A60,1151,2024-01-13 +A32,A16,283,2024-04-26 +A60,A68,1229,2024-05-23 +A41,A57,1679,2024-06-05 +A65,A55,923,2024-05-20 +A21,A61,540,2024-04-25 +A32,A36,1602,2024-07-15 +A67,A63,499,2024-06-09 +A36,A57,1471,2024-01-20 +A37,A31,697,2024-03-10 +A41,A70,293,2024-01-21 +A20,A30,1431,2024-04-08 +A20,A28,859,2024-01-17 +A53,A43,964,2024-05-18 +A54,A8,1715,2024-02-22 +A54,A50,1206,2024-07-16 +A3,A74,986,2024-04-07 +A1,A46,1553,2024-03-17 +A50,A54,1540,2024-05-17 +A70,A29,459,2024-05-04 +A35,A56,69,2024-05-04 +A50,A44,1400,2024-06-20 +A52,A22,1893,2024-04-29 +A17,A69,1867,2024-01-07 +A51,A76,1367,2024-05-24 +A4,A11,887,2024-06-13 +A18,A60,112,2024-02-16 +A34,A49,443,2024-03-24 +A59,A42,1568,2024-03-27 +A49,A36,1958,2024-07-11 +A54,A33,973,2024-01-21 +A3,A70,1959,2024-01-14 +A45,A29,150,2024-06-15 +A6,A4,418,2024-03-04 +A3,A20,268,2024-03-02 +A61,A15,1951,2024-05-24 +A28,A60,534,2024-06-28 +A48,A22,1253,2024-06-04 +A15,A21,231,2024-03-20 +A75,A4,1189,2024-03-20 +A49,A51,416,2024-07-02 +A10,A76,1711,2024-06-25 +A32,A14,1592,2024-06-27 +A39,A16,1612,2024-05-24 +A6,A45,887,2024-05-16 +A48,A9,1336,2024-05-09 +A44,A2,1694,2024-04-17 +A63,A14,1977,2024-04-20 +A47,A59,323,2024-06-30 +A56,A23,1078,2024-07-06 +A35,A69,1000,2024-07-17 +A60,A56,1223,2024-07-06 +A35,A42,1711,2024-03-03 +A12,A36,509,2024-04-25 +A60,A73,1378,2024-06-05 +A49,A44,1022,2024-01-08 +A42,A24,444,2024-05-04 +A46,A34,582,2024-03-28 +A36,A72,1068,2024-01-03 +A25,A11,1484,2024-03-02 +A53,A63,1562,2024-05-22 +A31,A61,1467,2024-06-14 +A63,A58,200,2024-01-05 +A38,A29,1426,2024-04-13 +A32,A40,1201,2024-06-18 +A48,A61,1097,2024-05-21 +A45,A55,1137,2024-07-09 +A43,A46,939,2024-06-28 +A35,A40,482,2024-03-05 +A16,A25,254,2024-03-21 +A69,A24,453,2024-02-19 +A62,A36,1217,2024-07-04 +A68,A37,1715,2024-01-26 +A25,A38,749,2024-02-28 +A23,A39,1460,2024-01-04 +A69,A17,103,2024-03-11 +A7,A71,1438,2024-03-15 +A17,A63,1797,2024-01-27 +A2,A74,971,2024-03-13 +A62,A57,387,2024-03-28 +A7,A33,243,2024-05-02 +A9,A52,161,2024-05-05 +A74,A7,315,2024-02-08 +A73,A39,518,2024-01-22 +A16,A72,862,2024-07-14 +A29,A67,932,2024-04-07 +A57,A39,888,2024-05-30 +A40,A73,133,2024-06-07 +A13,A27,442,2024-06-09 +A34,A11,501,2024-02-10 +A23,A71,330,2024-01-20 +A1,A53,1421,2024-04-25 +A61,A38,484,2024-01-09 +A37,A59,1417,2024-01-19 +A30,A34,1217,2024-06-09 +A26,A55,1125,2024-01-30 +A29,A20,1702,2024-03-09 +A19,A10,349,2024-01-16 +A40,A73,909,2024-03-14 +A16,A60,632,2024-06-25 +A52,A35,1115,2024-05-08 +A64,A57,1234,2024-01-21 +A6,A56,670,2024-07-07 +A33,A4,478,2024-01-24 +A74,A76,1576,2024-01-06 +A35,A74,1572,2024-01-11 +A23,A61,1344,2024-05-12 +A57,A36,1208,2024-02-16 +A56,A63,972,2024-01-24 +A45,A53,667,2024-03-26 +A14,A21,853,2024-03-25 +A64,A37,1945,2024-06-18 +A52,A71,941,2024-01-10 +A1,A34,822,2024-03-02 +A34,A65,831,2024-03-23 +A65,A1,1493,2024-03-05 +A23,A65,913,2024-05-28 +A65,A14,1344,2024-04-25 +A14,A23,1173,2024-02-20 +A39,A65,973,2024-04-29 +A65,A26,555,2024-04-12 +A26,A39,1030,2024-03-15 +A20,A48,1137,2024-04-06 +A48,A21,1010,2024-05-26 +A21,A20,952,2024-05-10 +A70,A68,552,2024-05-27 +A68,A1,773,2024-03-17 +A1,A70,634,2024-04-30 diff --git a/json/json.sql b/docker-entrypoint-initdb.d/9_json.sql similarity index 79% rename from json/json.sql rename to docker-entrypoint-initdb.d/9_json.sql index 5c343c9..644bb16 100644 --- a/json/json.sql +++ b/docker-entrypoint-initdb.d/9_json.sql @@ -1,3 +1,8 @@ +create table item ( + id integer primary key, + data jsonb +); + DO $$ DECLARE f TEXT; @@ -8,13 +13,13 @@ BEGIN BEGIN RAISE NOTICE 'Import du fichier : %', f; - INSERT INTO item (id, caracteristiques) + INSERT INTO item (id, data) VALUES ( replace(f, '.json','')::bigint, pg_read_file('/tmp/json/' || f)::jsonb ) ON CONFLICT (id) DO UPDATE - SET caracteristiques = EXCLUDED.caracteristiques; + SET data = EXCLUDED.data; EXCEPTION WHEN OTHERS THEN RAISE WARNING 'Erreur lors de l''import du fichier % : %', f, SQLERRM; diff --git a/mongo-init/01-import.sh b/mongodb-entrypoint-initdb.d/1_import.sh old mode 100644 new mode 100755 similarity index 77% rename from mongo-init/01-import.sh rename to mongodb-entrypoint-initdb.d/1_import.sh index a275a14..758f4d8 --- a/mongo-init/01-import.sh +++ b/mongodb-entrypoint-initdb.d/1_import.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -for file in /docker-entrypoint-initdb.d/*.json; do +for file in /initdb.d/commandes/*.json; do collection=$(basename "$file" .json) echo "Importing $collection..." mongoimport --db mydb --collection "$collection" --file "$file" --jsonArray