reduce number of multiple values to be inserted - Mailing list pgsql-general

From tango ward
Subject reduce number of multiple values to be inserted
Date
Msg-id CAA6wQLLRSCkVrxmo23pc1sbyW0rr5SQX8bTfMXA3WpgmH=48rQ@mail.gmail.com
Whole thread Raw
Responses Re: reduce number of multiple values to be inserted  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: reduce number of multiple values to be inserted  (Rob Sargent <robjsargent@gmail.com>)
Re: reduce number of multiple values to be inserted  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: reduce number of multiple values to be inserted  (Steven Lembark <lembark@wrkhors.com>)
List pgsql-general

Hi,

I am working on inserting multiple values for a table. I need to insert 3 values of data for each age of the students from the same village. It will be 3 different ages of student per village.

My sample code:


curr_pgsql.execute('''
                   INSERT INTO student (created, modified, name,
                                                    address, age, level
                                                    )
                   VALUES (current_timezone, current_timezone,
                           'Scott', 'Malayan Village', 21, 2),
                          (current_timezone, current_timezone,
                           'Ben', 'Malayan Village', 21, 2),
                          (current_timezone, current_timezone,
                           'Scott', 'Malayan Village', 21, 2),
                        
                          (current_timezone, current_timezone,
                           'Andrew', 'Malayan Village', 25, 2),
                          (current_timezone, current_timezone,
                           'Larry', 'Malayan Village', 25, 2),
                          (current_timezone, current_timezone,
                           'Adam', 'Malayan Village', 25, 2),
                         
                          (current_timezone, current_timezone,
                           'Elisse', 'Malayan Village', 27, 2),
                          (current_timezone, current_timezone,
                           'Xena', 'Malayan Village', 27, 2),
                          (current_timezone, current_timezone,
                           'Karen', 'Malayan Village', 27, 2)

I will repeat the same process for 13 villages so that will be 117 of values. I would like to know if there's a way to reduce the script? This has to be done strictly via script.


Thanks,
J

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: existence of a savepoint?
Next
From: "David G. Johnston"
Date:
Subject: Re: reduce number of multiple values to be inserted