Cursor (keyset) pagination is faster than OFFSET on large tables — and immune to dupes/skips when rows shift. Pass the last seen ID and direction; get the next page.
Safely interpolate a variable-length list into a "WHERE col IN (...)" clause. Returns the SQL fragment plus the bound parameters — never concatenate user values into SQL.
Open a PDO connection with all the options you almost always want: real prepared statements, exceptions on error, associative-array fetch mode, UTF-8 charset.
Insert many rows in one round-trip using executemany. Orders-of-magnitude faster than a loop of single inserts — and the driver handles batching/parametrization for you.
`database/sql` is driver-agnostic — pick a driver (`pgx/stdlib`, `go-sql-driver/mysql`, `mattn/sqlite3`). Always `defer db.Close()` only on app exit; the pool is meant to be long-lived.
The modern SQLAlchemy 2.0 style: typed Mapped[] columns, the new `select()` API, and Session.scalars() for clean row access. Replaces the legacy Query syntax.
Stdlib sqlite3 is fine for embedded / small workloads. Use `with conn:` for automatic commit/rollback, and a row_factory so you get dicts (or namedtuples) instead of bare tuples.
Wrap your transaction in a function that commits on success and rolls back on error or panic. Drop-in: pass any `func(*sql.Tx) error` and forget about manual cleanup.
Run a closure inside a transaction. Commits on success, rolls back on any exception, then re-throws so the caller can react. Avoids the bug-prone copy-paste of begin/commit/rollBack.
Insert a list of rows in one round trip by building a multi-VALUES statement with placeholders. Orders-of-magnitude faster than looping single INSERTs.
A MySQL upsert helper: insert a row, or if a unique key collides, update the same row with the new values. Returns whether the row was inserted (true) or updated (false).