X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=libs%2Fluci-lib-nixio%2FaxTLS%2Fwww%2Flua%2Fprepara_sql2.lua;fp=libs%2Fluci-lib-nixio%2FaxTLS%2Fwww%2Flua%2Fprepara_sql2.lua;h=6a37c2fef7f37fc4fa51998ece3dc055f341ba35;hb=1bb4822dca6113f73e3bc89e2acf15935e6f8e92;hp=0000000000000000000000000000000000000000;hpb=9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4;p=project%2Fluci.git diff --git a/libs/luci-lib-nixio/axTLS/www/lua/prepara_sql2.lua b/libs/luci-lib-nixio/axTLS/www/lua/prepara_sql2.lua new file mode 100644 index 000000000..6a37c2fef --- /dev/null +++ b/libs/luci-lib-nixio/axTLS/www/lua/prepara_sql2.lua @@ -0,0 +1,31 @@ +#!/usr/local/bin/lua + +MAX_ROWS = arg[1] or 10 + +require"postgres" + +local env = assert (luasql.postgres ()) +local conn = assert (env:connect ("luasql-test", "tomas")) + +-- Apaga restos de outros testes. +conn:execute "drop table t2" +conn:execute "drop table t1" + +-- Criando as tabelas. +assert (conn:execute [[create table t1 ( + a int, + b int +)]]) +assert (conn:execute [[create table t2 ( + c int, + d int +)]]) + +-- Preenchedo as tabelas. +for i = 1, MAX_ROWS do + local ii = 2*i + assert (conn:execute (string.format ([[ +insert into t1 values (%d, %d); +insert into t2 values (%d, %d);]], + ii, i, ii, i))) +end