Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
hoity-toity french names generator in pure postgreSQL single query
SELECT *
FROM (
SELECT
(
SELECT concat('Marie-', string_agg(x,'-')) as name_first_female
FROM (
select start_arr[ 1 + ( (random() * 100)::int) % 32 ]
FROM
(
select '{Claude,Thérèse,Géraldine,Sylvie,Sophie,Solange,Vivianne,Cunégonde,Albertine,Charlotte,Caroline,Célestine,Bérangère,Sylvianne,Alphonsine,Claire,Françoise,Chantal,Geneviève,Christine,Louise,Adeline,Céleste,Angélique,Clothilde,Jeanne,Pierre,Valentine,Paule,Noëlle,Lise,Cécile}'::text[] as start_arr
) syllarr,
-- need 3 syllabes, and force generator interpretation with the '*0' (else 3 same syllabes)
generate_series(1, 1 + ( ( (generator::int % 3) * (random() * 0.5))::int % 3))
) AS con_name_female(x)
),
(
SELECT concat('Jean-', string_agg(y,'-')) as name_first_male
FROM (
select start_arr[ 1 + ( (random() * 100)::int) % 33 ]
FROM
(
select '{François,Pierre,Michel,Sylvain,Sébastien,Eudes,Raymond,Claude,Régis,Charles,Maxence,Célestin,Baptiste,Grégoire,Hubert,Antonin,Stanislas,Gérald,Albert,Marie,Guy,Yves,Louis,Gabriel,Jérémie,Bartholomé,Mathieu,Vincent,Nicolas,Joachim,Olivier,Daniel,Philippe}'::text[] as start_arr
) syllarr,
-- need 3 syllabes, and force generator interpretation with the '*0' (else 3 same syllabes)
generate_series(1, 1 + ( ( (generator::int % 3) * (random() * 0.5))::int % 3))
) AS con_name_male(y)
),
(
SELECT concat(last_name_part1a,last_char) as last_name_part1
FROM (
SELECT initcap(concat(string_agg(z1,''))) as last_name_part1a
FROM (
select last_arr[ 1 + ( (random() * 100 + (generator * 0))::int) %35 ]
FROM
(
select '{cu,char,bar,rau,reau,ban,beau,che,choi,moi,dur,dup,bou,gre,gru,choi,chau,col,ast,ara,ame,aud,souch,chon,bon,cheau,tallo,lio,chau,ron,rency,ramb}'::text[] as last_arr
) sub1,
generate_series(1, 3 + (generator*0))
) AS con_name_first(z1)
) sub2,
(
select last_last[ 1 + ( (random() * 10 + (generator * 0))::int) % 6] as last_char
FROM (
select '{x,t,d,e,s}'::text[] as last_last
) sub3
) sub4
),
(
select part_arr[ 1 + ( (random() * 100 + (generator * 0))::int) % 50 ] as last_name_part2
FROM
(
select '{II,III,De Loinloin,De Meumeu,De Parloin,De Parlà,De MontLoin,De Vallointain,De Perpète,De Pétaouchnok,De Trifouillis-Les-Oies,De Clochemerle,Du Troupaumé,De Saint-glin-glin,De Berdouille,De Macapète,De Foufnie,De Pamparigouste,De GlinGlin,De Linlin,De Fouillard,D''Apeuprès,D''Icibas,D''Autemps,D''Auloin}'::text[] as part_arr
) sub
),
generator as id
FROM generate_series(1,1000) as generator
) main_sub
;
Owner

regilero commented Jun 27, 2017

Sample results:

     name_first_female      |     name_first_male      | last_name_part1  |     last_name_part2     |  id  
----------------------------+--------------------------+------------------+-------------------------+------
 Marie-Bérangère            | Jean-Daniel              | Cheauronbonx     |                         |    1
 Marie-Pierre               | Jean-Charles-Antonin     | Grebonamet       | De Clochemerle          |    2
 Marie-Claude               | Jean-Louis               | Bardurraus       |                         |    3
 Marie-Thérèse              | Jean-Olivier             | Moisouchtallot   |                         |    4
 Marie-Pierre-Claire        | Jean-Stanislas-Raymond   | Cheautalloamed   |                         |    5
 Marie-Noëlle               | Jean-Marie               | Bouarad          | De Macapète             |    6
 Marie-Chantal              | Jean-Albert              | Audrambbond      |                         |    7
 Marie-Cécile-Sylvianne     | Jean-Charles-Joachim     | Reaugruaudx      |                         |    8
 Marie-Angélique            | Jean-Sébastien           | Chereaubare      |                         |    9
 Marie-Sylvie               | Jean-Philippe            | Reauchauasts     | De MontLoin             |   10
 Marie-Paule-Christine      | Jean-Eudes               | Checurambt       |                         |   11
 Marie-Célestine            | Jean-Nicolas             | Chaurauliot      | Du Troupaumé            |   12
 Marie-Lise                 | Jean-Gérald              | Rencyastbout     |                         |   13
 Marie-Solange-Solange      | Jean-François            | Amechauraux      |                         |   14
 Marie-Charlotte            | Jean-Mathieu             | Gruarad          | De Fouillard            |   15
 Marie-Jeanne               | Jean-Albert              | Araaudchard      |                         |   16
 Marie-Céleste-Christine    | Jean-Mathieu-Gabriel     | Colsouchdup      |                         |   17
 Marie-Chantal              | Jean-Hubert              | Liocheaurambe    |                         |   18
 Marie-Géraldine            | Jean-Sébastien           | Durduparax       | Du Troupaumé            |   19
 Marie-Albertine-Lise       | Jean-Mathieu             | Dupchoichoie     |                         |   20
 Marie-Geneviève            | Jean-François            | Chaubanboux      | De Berdouille           |   21
 Marie-Clothilde            | Jean-Bartholomé          | Chautallot       |                         |   22
 Marie-Sophie               | Jean-Louis-Régis         | Choigrue         |                         |   23
 Marie-Claude               | Jean-Charles             | Durastmoit       | De Perpète              |   24
 Marie-Sophie               | Jean-François            | Audrencybons     |                         |   25
 Marie-Charlotte-Alphonsine | Jean-Maxence             | Cuaudgrux        | De Parlà                |   26
 Marie-Céleste              | Jean-François            | Choichauches     | De Linlin               |   27
 Marie-Sophie               | Jean-Raymond             | Bargrureaue      |                         |   28
 Marie-Cunégonde-Alphonsine | Jean-Grégoire            | Audbouamee       |                         |   29
 Marie-Chantal              | Jean-Jérémie             | Grechond         |                         |   30
 Marie-Sylvianne            | Jean-Antonin             | Astrencyaude     |                         |   31
 Marie-Geneviève-Jeanne     | Jean-Gabriel             | Cuchare          | De Meumeu               |   32
 Marie-Françoise            | Jean-Joachim             | Liocucolx        | De GlinGlin             |   33
 Marie-Chantal              | Jean-Claude              | Cheauaraamet     |                         |   34
 Marie-Géraldine-Lise       | Jean-Guy                 | Arabonmoi        |                         |   35
 Marie-Sylvianne            | Jean-Pierre              | Tallobanliox     | De Trifouillis-Les-Oies |   36
 Marie-Céleste              | Jean-Gabriel             | Raumoirons       |                         |   37
 Marie-Caroline-Chantal     | Jean-Grégoire-Hubert     | Cheauron         |                         |   38
 Marie-Christine            | Jean-Philippe            | Rambastbons      |                         |   39
 Marie-Geneviève            | Jean-Raymond             | Choigrechoix     | Du Troupaumé            |   40
(...)
Owner

regilero commented Jun 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment