From: Nicolas Boisselier Date: Mon, 21 Nov 2016 11:56:03 +0000 (+0000) Subject: dbq for docker X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=07606476f3501e7a43ef829ffba99fc170ed4d5b;p=nb.git dbq for docker --- diff --git a/etc/dbq/shell.php b/etc/dbq/shell.php index e3cffec6..00c3b453 100644 --- a/etc/dbq/shell.php +++ b/etc/dbq/shell.php @@ -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', ], ]; diff --git a/etc/dbq/zzz-all.php b/etc/dbq/zzz-all.php index a8491772..abd47f35 100644 --- a/etc/dbq/zzz-all.php +++ b/etc/dbq/zzz-all.php @@ -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; diff --git a/lib/php/db.php b/lib/php/db.php index 32d9b6d4..527f2e6b 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -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; } diff --git a/share/db/shell.db b/share/db/shell.db index c138a646..f8fae83d 100644 Binary files a/share/db/shell.db and b/share/db/shell.db differ diff --git a/share/db/update.sh b/share/db/update.sh index 32fec4f5..e516313c 100755 --- a/share/db/update.sh +++ b/share/db/update.sh @@ -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 diff --git a/src/Docker/php/Dockerfile b/src/Docker/php/Dockerfile index 4c35d058..d011c27f 100644 --- a/src/Docker/php/Dockerfile +++ b/src/Docker/php/Dockerfile @@ -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 'Welcom to php:7.0-fpm-alpine

Welcom to php:7.0-fpm-alpine

' > /var/www/html/index.php