Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNozJ-0007p3-La for pgsql-general@arkaria.postgresql.org; Wed, 30 May 2018 00:29:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fNozI-0000Gu-Fk for pgsql-general@arkaria.postgresql.org; Wed, 30 May 2018 00:29:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNozI-0000GU-8B for pgsql-general@lists.postgresql.org; Wed, 30 May 2018 00:29:12 +0000 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fNozF-0007qw-JT for pgsql-general@lists.postgresql.org; Wed, 30 May 2018 00:29:11 +0000 Received: by mail-pf0-x22c.google.com with SMTP id p19-v6so3852184pff.13 for ; Tue, 29 May 2018 17:29:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=dvZ0Daal5uVxBrz1ABLsu3ZAUjm3c7MQSfhGh7Q/yNY=; b=idIym7Avh8wYqA3Y/TMVgJp9wHMZKDMP39chgs1jrrSGqHXdzVhAwaL3uS49ztoQQz 4MeEqRMb4OOK5H7DRnT9/UgSvjrGrV4D+aF4+xCcCHTN99HX4klVHDDlv97tRUP3gyX3 +M7db/kWN8Eejktp1nvkZIY6LowZqiJfx7LyfZciwPekL6gS9T13KArUGoFmO7tj+e+M 0rHnDnq2qXgmQPgvCTn89BkC8YIQ8NgHKOfnt6V1LyrukziYifOHzqUe0B9liQg2xRQJ nBzwXtv6ymvkJK2WYKFuVt9VEIkPMnB7T+b06cE3tC2IfRVEsEbpWQKAc9ectjQTE3iJ 6TvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=dvZ0Daal5uVxBrz1ABLsu3ZAUjm3c7MQSfhGh7Q/yNY=; b=TvX4dPTvbrHR/vXW9htEGNHQUG3ze2Ov6KKCA3+xP3H4hBkXH7Jl9FTR9IDcJ0AWQa HOtwZa0wkr0M+7w3ffMRYiFJAAIJKhqWQ9BM9flYip/sQ6L6fMW2w2KT15AMdtb0XxUR caY3/O1K0Qfdgc0EQ8UDA9v58F+0Bew4FiMSDG9sFvy6pQOT7hFXJLf62cbypS25hKyS BifRXqkvgHCp2Cx8M4bAHkGQHknSWGeNMIwqaTxhat/V728rHqEFKHwS9SeYH7Ia24b8 o59/VOHMllIkawCbZdJwhFL1PNJCfDZCy2eFKcdzAcMmSnc/qW+JodL+2nshE811GFAu udCA== X-Gm-Message-State: ALKqPwdIVBXOmcywyExaA5vGDPmEr0d5gyDE93OOgqmqYl4m5Vp+rGsY 4+KmWM2oXGBplwcsbTBKjBY= X-Google-Smtp-Source: ADUXVKKKgJJ21fNG9VGG3k8yAPbf/Dba0H/mgSJVeeFYdfOgFDuXpIFlJTQ04auCAgIE7KZtzb29sg== X-Received: by 2002:a62:4cca:: with SMTP id e71-v6mr528059pfj.171.1527640147337; Tue, 29 May 2018 17:29:07 -0700 (PDT) Received: from kitselas.hci.utah.edu ([155.100.47.4]) by smtp.gmail.com with ESMTPSA id 23-v6sm85357147pfs.147.2018.05.29.17.29.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 17:29:06 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: Re: reduce number of multiple values to be inserted From: Rob Sargent In-Reply-To: Date: Tue, 29 May 2018 18:29:05 -0600 Cc: "pgsql-generallists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <0478A9B3-9186-45FA-A9B0-303CEBD795C7@gmail.com> References: To: tango ward X-Mailer: Apple Mail (2.3445.6.18) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On May 29, 2018, at 6:10 PM, tango ward wrote: >=20 >=20 > Hi, >=20 > 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. >=20 > My sample code: >=20 >=20 > 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), > =20 > (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), > =20 > (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) >=20 > 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. >=20 >=20 > Thanks, > J >=20 Is =E2=80=9Ccurrent_timezone, current_timezone=E2=80=9D just a typo? I = think you need to make the 117 data lines and load using \copy =20