Skip to content

Instantly share code, notes, and snippets.

View julian-calleja's full-sized avatar

Julian Calleja julian-calleja

View GitHub Profile
@jeroos
jeroos / gist:c4336e8e177ab634a91968431d8af4cd
Last active June 20, 2025 17:43
Streamlining AWS Lambda with DuckDB for Dynamic Data Handling
import json
import os
import duckdb
import boto3
import datetime
from typing import Any, Dict
def construct_prepared_sql_and_params(sql_template, bind_params):
single_value_params = {k: v for k, v in bind_params.items() if not isinstance(v, list)}
@bradtraversy
bradtraversy / docker-help.md
Last active July 7, 2025 02:24
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@fabriziomello
fabriziomello / pgbouncer-show-dblink-fdw.sql
Last active October 5, 2022 12:40
pgbouncer-show-dblink-fdw
@anvk
anvk / psql_useful_stat_queries.sql
Last active June 1, 2025 16:17
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@cristianp6
cristianp6 / postgresql_changes_tracking.sql
Last active November 25, 2024 23:53
Log row changes in PostgreSQL - Any advice/improvement is welcome ;-)
/**
* Creates a "logging" schema with an "history" table where are stored records in JSON format
*
* Requires PostgreSQL >= 9.3 since data is stored in JSON format
*
* Credits: http://www.cybertec.at/2013/12/tracking-changes-in-postgresql/
*/
/* Create a schema dedicated to logs */
CREATE SCHEMA logging;
@ghl3
ghl3 / _ImmutableDatabase
Last active October 24, 2024 13:50
Implementation of an immutable database in postgres
We couldn’t find that file to show.
@petere
petere / pgbouncer-schema.sql
Created March 25, 2015 00:13
views for accessing PgBouncer statistics via dblink
CREATE EXTENSION dblink;
-- customize start
CREATE SERVER pgbouncer FOREIGN DATA WRAPPER dblink_fdw OPTIONS (host 'localhost',
port '6432',
dbname 'pgbouncer');
CREATE USER MAPPING FOR PUBLIC SERVER pgbouncer OPTIONS (user 'pgbouncer');
-- customize stop
@Kartones
Kartones / postgres-cheatsheet.md
Last active July 6, 2025 07:16
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 4, 2025 11:28
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'