use Socket;
use DBI;
use Encode qw(decode encode);

# Parametres de connection a la base de donnees
$bd    = '/tmp/memory/fah.db';
$identifiant = '';      # identifiant
$motdepasse  = '';

# Connection a la base de donnees mysql
print("Connexion a la base de donnees $bd\n");
$db = DBI->connect(
        "DBI:SQLite:dbname=$bd",
        $identifiant, $motdepasse, {RaiseError => 1}
      ) or die "Connection impossible a la base de donnees $bd !\n $! \n $@\n$DBI::errstr";

open(posFile, "pos.res"); $b1 = <posFile>; close(posFile);

$semaine = 0;
$b1 = $b1+7;
print("\n");
while ($semaine < 16) {
  $membre = 0;
  $b1 = $b1-7;
  $ErrNum = 0;
  print("SELECT count(rec) FROM Alliance WHERE rec = ".$b1."\n");
  $membre = $db->selectrow_array("SELECT count(rec) FROM Alliance WHERE rec = ".$b1);
  if ($membre > 0) {
    print("Membre semaine[".$semaine."]= ".$membre."\n");
    $mm[$semaine] = $membre;
  }
  $semaine++;
}

$db->disconnect();

