<commit_before>// Copyright (c) 2016-2020 <NAME> and Dr. <NAME>
// Please see LICENSE for license or visit https://github.com/taocpp/taopq/

#include "../macros.hpp"

#include <tao/pq.hpp>

#include <iostream>

void run()
{
   // open a connection
   const auto conn = tao::pq::connection::create( "dbname=template1" );

   // execute statements directly
   conn->execute( "DROP TABLE IF EXISTS tao_example" );
   conn->execute( "CREATE TABLE tao_example ( a INTEGER PRIMARY KEY, b INTEGER, c TEXT NOT NULL )" );

   // preparing a statement is optional, but often recommended
   conn->prepare( "insert", "INSERT INTO tao_example VALUES ( $1, $2, $3 )" );

   // use a transaction if needed
   {
      const auto tr = conn->transaction();

      // execute statement with parameters directly
      tr->execute( "INSERT INTO tao_example VALUES ( $1, $2, $3 )", 1, 42, "foo" );

      // execute prepared statement with parameters
      tr->execute( "insert", 2, tao::pq::null, "Hello, world!" );<commit_msg>Allow CI to execute the example<commit_after>// Copyright (c) 2016-2020 <NAME> and Dr. <NAME>
// Please see LICENSE for license or visit https://github.com/taocpp/taopq/

#include "../macros.hpp"

#include <tao/pq.hpp>

#include <iostream>

void run()
{
   // overwrite the default with an environment variable if needed
   const auto connection_string = tao::pq::internal::getenv( "TAOPQ_TEST_DATABASE", "dbname=template1" );

   // open a connection
   const auto conn = tao::pq::connection::create( connection_string );

   // execute statements directly
   conn->execute( "DROP TABLE IF EXISTS tao_example" );
   conn->execute( "CREATE TABLE tao_example ( a INTEGER PRIMARY KEY, b INTEGER, c TEXT NOT NULL )" );

   // preparing a statement is optional, but often recommended
   conn->prepare( "insert", "INSERT INTO tao_example VALUES ( $1, $2, $3 )" );

   // use a transaction if needed
   {
      const auto tr = conn->transaction();

      // execute statement with parameters directly
      tr->execute( "INSERT INTO tao_example VALUES ( $1, $2, $3 )", 1, 42, "foo" );

      // execute prepared statement with parameters
      tr->execute( "insert", 2, tao::pq::null, "Hello, world!" );
{'fraction_non_alphanumeric': 0.13844757149341808, 'fraction_numerical': 0.017249205628688154, 'mean_word_length': 3.4346076458752517, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6683707', 'n_tokens_mistral': 721, 'n_tokens_neox': 654, 'n_words': 236}