<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Database on Micha Kops&#39; Tech Notes</title>
    <link>https://www.hascode.com/tags/database/</link>
    <description>Recent content in Database on Micha Kops&#39; Tech Notes</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>Copyright © 2010 - 2025 Micha Kops. #e9d956c0c0154a221ad83c925346a8fa0e72f866</copyright>
    <lastBuildDate>Wed, 29 Mar 2023 00:00:00 +0200</lastBuildDate>
    <atom:link href="https://www.hascode.com/tags/database/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Postgres with docker-compose or Docker and pg_stat_statements enabled</title>
      <link>https://www.hascode.com/postgres-with-docker-compose-or-docker-and-pg_stat_statements-enabled/</link>
      <pubDate>Wed, 29 Mar 2023 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/postgres-with-docker-compose-or-docker-and-pg_stat_statements-enabled/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://www.postgresql.org/docs/9.3/pgstatstatements.html&#34;&gt;pg_stat_statements&lt;/a&gt; is useful to gather performance information
about queries so lets add it to our dockerized postgres database.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_using_docker_compose&#34;&gt;Using docker-compose&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Using &lt;a href=&#34;https://docs.docker.com/compose/&#34;&gt;docker-compose&lt;/a&gt; we just need to add the following &lt;code&gt;docker-compose.yaml&lt;/code&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;title&#34;&gt;docker-compose.yml&lt;/div&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;version: &amp;#39;3.5&amp;#39;

services:
  postgres:
    container_name: postgres_container
    image: postgres
    ports:
      - &amp;#34;5432:5432&amp;#34;
    volumes:
      - /var/lib/postgresql/data
    # used for query profiling, deactivate for enhanced performance
    command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c max_connections=200
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: thepassword&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;We simply start our Postgres database with &lt;code&gt;docker-compose&lt;/code&gt;:&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>MySQL and phpMyAdmin Setup with Docker-Compose</title>
      <link>https://www.hascode.com/mysql-and-phpmyadmin-setup-with-docker-compose/</link>
      <pubDate>Fri, 14 May 2021 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/mysql-and-phpmyadmin-setup-with-docker-compose/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;sidebarblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;div class=&#34;title&#34;&gt;Goals&lt;/div&gt;
&lt;div class=&#34;olist arabic&#34;&gt;
&lt;ol class=&#34;arabic&#34;&gt;
&lt;li&gt;
&lt;p&gt;Setup mySQL with phpMyAdmin connected using docker-compose (for development purpose)&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;ulist&#34;&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;docker-compose installed&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_setup&#34;&gt;Setup&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;This is our &lt;code&gt;docker-compose.yml&lt;/code&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;version: &amp;#39;3.2&amp;#39;

services:
   db:
      image: mysql:8.0
      container_name: mysql-container
      restart: always
      ports:
       - &amp;#39;6603:3306&amp;#39;
      environment:
        MYSQL_ROOT_PASSWORD: 12345678

   app:
      depends_on:
       - db
      image: phpmyadmin/phpmyadmin
      container_name: phpmyadmin
      restart: always
      ports:
       - &amp;#39;8080:80&amp;#39;
      environment:
        PMA_HOST: db&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_running&#34;&gt;Running&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;docker-compose up
Starting mysql-container ... done
Starting phpmyadmin      ... done
Attaching to mysql-container, phpmyadmin
[..]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;admonitionblock tip&#34;&gt;
&lt;table&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;td class=&#34;icon&#34;&gt;
&lt;i class=&#34;fa icon-tip&#34; title=&#34;Tip&#34;&gt;&lt;/i&gt;
&lt;/td&gt;
&lt;td class=&#34;content&#34;&gt;
We may now login using the following ultra-secure credentials ;)
User: &lt;code&gt;root&lt;/code&gt;, Password: &lt;code&gt;12345678&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>WordPress Docker Setup</title>
      <link>https://www.hascode.com/wordpress-docker-setup/</link>
      <pubDate>Fri, 14 May 2021 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/wordpress-docker-setup/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;sidebarblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;div class=&#34;title&#34;&gt;Goals&lt;/div&gt;
&lt;div class=&#34;olist arabic&#34;&gt;
&lt;ol class=&#34;arabic&#34;&gt;
&lt;li&gt;
&lt;p&gt;Run WordPress via Docker / Docker-Compose&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Increase the Upload Filesize Limit&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_create_docker_compose_configuration&#34;&gt;Create Docker Compose Configuration&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Create a &lt;code&gt;docker-compose.yml&lt;/code&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;version: &amp;#39;3.1&amp;#39;

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress:/var/www/html

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: &amp;#39;1&amp;#39;
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db:&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_run_docker_compose_start_containers&#34;&gt;Run Docker Compose / Start Containers&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;docker-compose up
WARNING: Found orphan containers (wordpress-docker_phpmyadmin_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Starting wordpress-docker_db_1        ... done
Starting wordpress-docker_wordpress_1 ... done
Attaching to wordpress-docker_db_1, wordpress-docker_wordpress_1
[..]
db_1         | 2021-04-03T18:58:17.247963Z 0 [Note] mysqld: ready for connections.
db_1         | Version: &amp;#39;5.7.33&amp;#39;  socket: &amp;#39;/var/run/mysqld/mysqld.sock&amp;#39;  port: 3306  MySQL Community Server (GPL)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Using Throwaway Containers for Integration Testing with Java, JUnit 5 and Testcontainers.</title>
      <link>https://www.hascode.com/using-throwaway-containers-for-integration-testing-with-java-junit-5-and-testcontainers./</link>
      <pubDate>Wed, 30 Jan 2019 00:00:00 +0100</pubDate>
      <guid>https://www.hascode.com/using-throwaway-containers-for-integration-testing-with-java-junit-5-and-testcontainers./</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;A lot of boilerplate code is written when developers need to test their applications with different connected systems like databases, stream platforms and other collaborators.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Docker allows to handle those dependencies but there is still some glue code required to bind the container’s lifecycle and the configuration to the concrete integration test.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Testcontainers is a testing library that offers lightweight throwaway instances of anything able to run in a Docker container, with bindings to configure the specific containers and also provides wrappers to manage our own custom containers.&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Using jetstreamDB as in-memory Database for Java</title>
      <link>https://www.hascode.com/using-jetstreamdb-as-in-memory-database-for-java/</link>
      <pubDate>Sat, 30 Jun 2018 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/using-jetstreamdb-as-in-memory-database-for-java/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;JetstreamDB is a in-memory database engine for Java that claims to be built for ultra-high speed and the ability of managing complex data structures by storing real Java objects instead of serializing data structures to other database specific formats.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;In the following short example I would like to demonstrate how to create and read items from such a database by building a small article management sample app.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;imageblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;img src=&#34;jetstreamdb-intellij.png&#34; alt=&#34;Using jetstreamDB for Java&#34; width=&#34;520&#34; height=&#34;345&#34;/&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Creating and Providing HipChat Integrations with Atlassian Connect, Nodejs and Express</title>
      <link>https://www.hascode.com/creating-and-providing-hipchat-integrations-with-atlassian-connect-nodejs-and-express/</link>
      <pubDate>Tue, 18 Aug 2015 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/creating-and-providing-hipchat-integrations-with-atlassian-connect-nodejs-and-express/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;HipChat is Atlassian’s alternative to Slack and its solution to team collaboration chats. Atlassian Connect offers developer tools to bootstrap applications, connect to Atlassian’s cloud products with easy and in combination with HipChat’s REST APIs allows us to write integrations for such a chat server in no time.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;In the following tutorial I’d like to show how to write an integration within a few steps using Atlassian Connect, Node.js and Express and how to connect the integration to a HipChat server.&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>A short Overview of Neo4j Indexing Strategies</title>
      <link>https://www.hascode.com/a-short-overview-of-neo4j-indexing-strategies/</link>
      <pubDate>Sun, 25 Jan 2015 00:00:00 +0100</pubDate>
      <guid>https://www.hascode.com/a-short-overview-of-neo4j-indexing-strategies/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;When it comes to indexing in a Neo4j graph database, different options exist for a developer to create and maintain the index.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;In the following short examples I’d like to demonstrate different possibilities for index management.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;imageblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;img src=&#34;domain-model.png&#34; alt=&#34;domain model&#34;/&gt;
&lt;/div&gt;
&lt;div class=&#34;title&#34;&gt;Figure 1. Simple Domain Model&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_dependencies&#34;&gt;Dependencies&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Only one dependency is needed to run the following examples and start an embedded neo4j server – I’m using Gradle here to manage my dependencies but Maven, Ivy, SBT should work without a problem, too.&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Java Persistence API: Controlling the Second-Level-Cache</title>
      <link>https://www.hascode.com/java-persistence-api-controlling-the-second-level-cache/</link>
      <pubDate>Mon, 21 Apr 2014 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/java-persistence-api-controlling-the-second-level-cache/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Using the Java Persistence API and a decent persistence provider allows us to configure and fine-tune when and how the second level cache is used in our application.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;In the following short examples, we’re going to demonstrate those features written as JUnit test cases and running on a H2 in-memory database.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;imageblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;img src=&#34;persistence-configuration.png&#34; alt=&#34;persistence configuration&#34;/&gt;
&lt;/div&gt;
&lt;div class=&#34;title&#34;&gt;Figure 1. Persistence Unit Configuration&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_setup&#34;&gt;Setup&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;First of all we need some basic setup to run the following examples .. we need to select a JPA persistence provider and database, create a persistence-unit configuration and an environment to run tests on an in-memory database.&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Creating elegant, typesafe Queries for JPA, mongoDB Morphia and Lucene using Querydsl</title>
      <link>https://www.hascode.com/creating-elegant-typesafe-queries-for-jpa-mongodb-morphia-and-lucene-using-querydsl/</link>
      <pubDate>Thu, 13 Feb 2014 00:00:00 +0100</pubDate>
      <guid>https://www.hascode.com/creating-elegant-typesafe-queries-for-jpa-mongodb-morphia-and-lucene-using-querydsl/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Querydsl is a framework that allows us to create elegant, type-safe queries for a variety of different data-sources like Java Persistence API (JPA) entities, Java Data Objects (JDO), mongoDB with Morphia, SQL, Hibernate Search up to Lucene.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;In the following tutorial we’re implementing example queries for different environments – Java Persistence API compared with a JPQL and a criteria API query, mongoDB with Morphia and last but not least for Lucene.&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Docker Snippets</title>
      <link>https://www.hascode.com/docker-snippets/</link>
      <pubDate>Mon, 01 Mar 2010 00:00:00 +0100</pubDate>
      <guid>https://www.hascode.com/docker-snippets/</guid>
      <description>&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_restrict_network&#34;&gt;Restrict Network&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;admonitionblock tip&#34;&gt;
&lt;table&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;td class=&#34;icon&#34;&gt;
&lt;i class=&#34;fa icon-tip&#34; title=&#34;Tip&#34;&gt;&lt;/i&gt;
&lt;/td&gt;
&lt;td class=&#34;content&#34;&gt;
Can be useful when using a third-party image that we do not trust
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&#34;sect2&#34;&gt;
&lt;h3 id=&#34;_run_with_no_network&#34;&gt;Run with no network&lt;/h3&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;docker run --network none &amp;lt;image&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect2&#34;&gt;
&lt;h3 id=&#34;_run_with_private_isolated_network&#34;&gt;Run with private isolated network&lt;/h3&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;At least containers attached to this network can talk with another&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;docker network create --internal my_isolated_network
docker run --network my_isolated_network &amp;lt;image&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect2&#34;&gt;
&lt;h3 id=&#34;_block_using_firewall&#34;&gt;Block using firewall&lt;/h3&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;e.g. using &lt;code&gt;iptables&lt;/code&gt; or &lt;code&gt;ipfw&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;# Get container&amp;#39;s IP
docker inspect -f &amp;#39;{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}&amp;#39; &amp;lt;container_name&amp;gt;

# Block all outbound connections from that IP
sudo iptables -I DOCKER-USER -s &amp;lt;container_ip&amp;gt; -j DROP&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Postgres Snippets</title>
      <link>https://www.hascode.com/postgres-snippets/</link>
      <pubDate>Mon, 01 Mar 2010 00:00:00 +0100</pubDate>
      <guid>https://www.hascode.com/postgres-snippets/</guid>
      <description>&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_administration_configuration&#34;&gt;Administration &amp;amp; Configuration&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;sect2&#34;&gt;
&lt;h3 id=&#34;_connections&#34;&gt;Connections&lt;/h3&gt;
&lt;div class=&#34;sect3&#34;&gt;
&lt;h4 id=&#34;_show_max_connections_value_and_source&#34;&gt;Show Max Connections (value and source)&lt;/h4&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;SELECT setting, source, sourcefile, sourceline
FROM pg_settings
WHERE name = &amp;#39;max_connections&amp;#39;;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect3&#34;&gt;
&lt;h4 id=&#34;_set_max_connections&#34;&gt;Set Max Connections&lt;/h4&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;ALTER system SET max_connections = 250;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect3&#34;&gt;
&lt;h4 id=&#34;_kill_connections_for_a_database&#34;&gt;Kill Connections for a Database&lt;/h4&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;SELECT pg_terminate_backend(pid)
FROM pg_catalog.pg_stat_activity
-- we don&amp;#39;t want to kill our own connection
WHERE pid != pg_backend_pid()
-- we don&amp;#39;t want to kill connections to other databases
AND datname = &amp;#39;MYDATABASE&amp;#39;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect3&#34;&gt;
&lt;h4 id=&#34;_show_statement_timeout_settings_for_all_users&#34;&gt;Show Statement Timeout Settings for All Users&lt;/h4&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;SELECT r.rolname,
       (SELECT unnest(s.setconfig) FROM pg_db_role_setting s WHERE s.setrole = r.oid AND s.setconfig::text LIKE &amp;#39;%statement_timeout%&amp;#39; LIMIT 1) AS statement_timeout
FROM pg_roles r
WHERE r.rolcanlogin
ORDER BY r.rolname;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>SQL Snippets</title>
      <link>https://www.hascode.com/sql-snippets/</link>
      <pubDate>Mon, 01 Mar 2010 00:00:00 +0100</pubDate>
      <guid>https://www.hascode.com/sql-snippets/</guid>
      <description>&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_count_unique_all_values&#34;&gt;Count unique / all values&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;SELECT COUNT(DISTINCT &amp;lt;FIELDNAME&amp;gt;), COUNT(ALL &amp;lt;FIELDNAME&amp;gt;) FROM &amp;lt;TABLE&amp;gt;;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_partially_anonymize_e_mail_addresses&#34;&gt;Partially anonymize e-mail addresses&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;UPDATE &amp;lt;TABLE_NAME&amp;gt;
SET &amp;lt;EMAIL_FIELD&amp;gt;=
INSERT(
&amp;lt;EMAIL_FIELD&amp;gt;,
POSITION(&amp;#39;@&amp;#39; IN &amp;lt;EMAIL_FIELD&amp;gt;),
100,
CONCAT(FLOOR(1 + (RAND() * 100)),&amp;#39;@hascode.com&amp;#39;))
WHERE
POSITION(&amp;#39;@&amp;#39; IN &amp;lt;EMAIL_FIELD&amp;gt;)&amp;gt;0;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_find_duplicate_entries&#34;&gt;Find duplicate entries&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;SELECT COUNT(*), &amp;lt;FIELDNAME&amp;gt; FROM &amp;lt;TABLENAME&amp;gt;
GROUP BY &amp;lt;FIELDNAME&amp;gt;
HAVING COUNT(*)&amp;gt;1;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_mysql_fix_zero_dates_for_data_imports&#34;&gt;MySQL Fix Zero Dates for Data Imports&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;quoteblock&#34;&gt;
&lt;blockquote&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Error: ERROR 1067 (42000) at line 1234: Invalid default value for ‘datefield’&lt;/p&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;In newer MySQL Versions zero in date or zero dates are forbidden .. check this with:&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
  </channel>
</rss>
