Skip to content

Instantly share code, notes, and snippets.

@devyourcar
devyourcar / deletecspecificationdupes.sql
Created August 7, 2019 22:48
Delete duplicate cspecification records
DELETE FROM cspecificationvalues
WHERE id IN(
SELECT
id FROM (
SELECT
id, ROW_NUMBER() OVER (PARTITION BY cspecification_id, cengine_id ORDER BY id) AS row_num FROM cspecificationvalues) t
WHERE
t.row_num > 1);
@devyourcar
devyourcar / README.md
Created July 12, 2019 03:47
Postgresql launchd/cron backup

Postgresql daily backups

The following set of scripts will create daily backups for a specified database (8:45 am / when a computer reboots).

Installation

# Copy files to their respective folders then execute the following:

chmod u+x ~/scripts/auto_postgres_backup.sh
@devyourcar
devyourcar / update.sql
Last active July 2, 2019 01:32
postgres - csv update
# https://stackoverflow.com/questions/8910494/how-to-update-selected-rows-with-values-from-a-csv-file-in-postgres
CREATE TEMP TABLE tmp_x AS
SELECT
*
FROM
cmakes
LIMIT 0;
COPY tmp_x