fonction d'anonymisation
This commit is contained in:
parent
737f88988d
commit
47811943c1
@ -35,6 +35,18 @@ BEGIN
|
||||
END LOOP;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- Fonction pour anonymisation:
|
||||
-- inspirée par https://www.simononsoftware.com/random-string-in-postgresql/
|
||||
CREATE FUNCTION random_text_md5( integer ) returns text
|
||||
LANGUAGE SQL
|
||||
AS $$
|
||||
select upper( substring( (SELECT string_agg(md5(random()::TEXT), '')
|
||||
FROM generate_series(
|
||||
1,
|
||||
CEIL($1 / 32.)::integer)
|
||||
), 1, $1) );
|
||||
$$;
|
||||
"""
|
||||
)
|
||||
db.session.commit()
|
||||
|
@ -205,7 +205,9 @@ def _drop_ano_db(ano_db_name):
|
||||
"""drop temp database if it exists"""
|
||||
existing_databases = [
|
||||
s.split("|")[0].strip()
|
||||
for s in subprocess.check_output(["psql", "-l"]).split("\n")[3:]
|
||||
for s in subprocess.check_output(["psql", "-l"])
|
||||
.decode(scu.SCO_ENCODING)
|
||||
.split("\n")[3:]
|
||||
]
|
||||
if ano_db_name not in existing_databases:
|
||||
log("_drop_ano_db: no temp db, nothing to drop")
|
||||
|
Loading…
Reference in New Issue
Block a user