mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
added lua test cases
git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@128 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
31
www/lua/prepara_sql2.lua
Normal file
31
www/lua/prepara_sql2.lua
Normal file
@ -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
|
Reference in New Issue
Block a user