]> git.nbdom.net Git - nb.git/commitdiff
dbq for docker
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 21 Nov 2016 11:56:03 +0000 (11:56 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 21 Nov 2016 11:56:03 +0000 (11:56 +0000)
etc/dbq/shell.php
etc/dbq/zzz-all.php
lib/php/db.php
share/db/shell.db
share/db/update.sh
src/Docker/php/Dockerfile

index e3cffec6d4e89f7de6c629a2478da5064d35dcbb..00c3b4536e158f39fadd300ce4249d3393e03334 100644 (file)
@@ -6,6 +6,7 @@ if (true or !nb::is_vm()) $DBQ = [
   'shell' => [
     'type' => 'sqlite',
     'name' => 'shell',
+    'default_table' => 'shell_function',
     'host' => nb::ROOT_DIR.'/share/db/shell.db',
   ],
 ];
index a8491772637a20925c28a8dfd0bbf124fe81bf8c..abd47f35a5089a4671e16881e42dde61a3de3391 100644 (file)
@@ -41,6 +41,7 @@ if (!empty($DIR_SQLITE)) {
 $DBQ['all'] = [
   'host' => ':memory:',
   'type' => 'sqlite',
+  'name' => 'all',
   'pdo' => '',
   '_import' => [],
   #'order' => '0',
@@ -48,9 +49,12 @@ $DBQ['all'] = [
     PDO::ATTR_PERSISTENT => true,
   ],
   'tables' => [],
+  'types' => [
+    'sql_pre' => [],
+  ],
   'sql_pre' => [
     #'PRAGMA synchronous=NORMAL',
-    'PRAGMA busy_timeout = 1000',
+    'PRAGMA busy_timeout = 10000',
     'PRAGMA journal_mode=MEMORY',
   ],
 ];
@@ -70,7 +74,7 @@ foreach ($DBQ as $id => $db) {
   $fname = basename($db['host'],'.db');
   $fname = preg_replace('/\..*$/','',basename($db['host']));
 
-  #$DBQ['all']['types']['sql_pre'][] = "DETACH DATABASE '".$db['host']."'";
+  #array_unshift($DBQ['all']['types']['sql_pre'],"ATTACH DATABASE '".$db['host']."' as ".$fname);
   $DBQ['all']['types']['sql_pre'][] = "ATTACH DATABASE '".$db['host']."' as ".$fname;
   $DBQ['all']['_import'] = empty($DBQ['all']['_import']) ? [] : (array)$DBQ['all']['_import'];
   $DBQ['all']['_import'][] = $id;
index 32d9b6d44a0638d1030fc0273674e8093192e485..527f2e6bcc72b3d22c4f2bd4143c9db9a25776d0 100644 (file)
@@ -288,7 +288,11 @@ class Db extends nb {
       }
     }
 
+    #try {
     foreach ($this->sql_pre() as $s) { $this->conn->exec($s); }
+    #} catch (PDOException $e) {
+    #return false;
+    #}
 
     return true;
   }
@@ -1125,16 +1129,16 @@ class Db extends nb {
   public function sql_pre() {
     $return = [];
 
-    foreach ((array)$this->conf_type('sql_pre') as $s) {
-      if (!empty($s)) $return[] = $s;
-    }
-
     if (!empty($this->sql_pre)) {
       foreach ((array)$this->sql_pre as $s) {
         if (!empty($s)) $return[] = $s;
       }
     }
 
+    foreach ((array)$this->conf_type('sql_pre') as $s) {
+      if (!empty($s)) $return[] = $s;
+    }
+
     return $return;
   }
 
index c138a646dfcdbd58a461a04857188d75181875c2..f8fae83dc5b580d8dea9b59bf896d00a70578146 100644 (file)
Binary files a/share/db/shell.db and b/share/db/shell.db differ
index 32fec4f54ca8f5658fe4b064e85d447ecac6b994..e516313c33491c2223b3e4746b713b488e3501f6 100755 (executable)
@@ -2,6 +2,8 @@
 set -e
 cd "$(dirname "$0")"
 
+echo "Create shell.db"
+
 (
 
 cat << EOF
@@ -14,5 +16,6 @@ shell_functions2sql shell_function
 cat << EOF
 COMMIT;
 EOF
-) | sqlite3 local.db.tmp && mv local.db.tmp local.db
+
+) | sqlite3 shell.db.tmp && mv shell.db.tmp shell.db
 
index 4c35d05843fc0ca7e891bf48d9ee416bdcbd2ae9..d011c27f1e74378ed4412a7b7faac50e5083ed59 100644 (file)
@@ -4,7 +4,7 @@ RUN mkdir /opt
 # Install Postgre PDO
 #RUN export DEBIAN_FRONTEND=noninteractive && apt-get -q=2 update && apt-get -q=2 -y install libpq-dev
 #RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql
-RUN set -ex && apk --no-cache add postgresql-dev sqlite perl perl-uri perl-encode
+RUN set -ex && apk --no-cache add postgresql-dev sqlite perl perl-uri
 RUN docker-php-ext-install pdo pdo_mysql pdo_sqlite pdo_sqlite pdo_pgsql pgsql
 RUN mkdir -p /var/www/html && echo '<html><head><title>Welcom to php:7.0-fpm-alpine</title></head><body><h1>Welcom to php:7.0-fpm-alpine</h1></body></html>' > /var/www/html/index.php