cgi and sqlite question...

Joe Wilson <[email protected]> Mon, 7 Jun 2004 09:49:02 -0700
Newsgroups gmane.comp.lang.lua.luacheia
Message-ID <[email protected]>
--Apple-Mail-1-945559749
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

I'm trying to get sqlite to work with a cgi script in Lua.

When I call SELECT Lua returns an unknown error.

Does anyone have a working example of using the sqlite module with cgi 
they can share?

Thanks in advance,

-joe-

Example code of my problem:

#!/usr/local/bin/luacheia5 	

-- Load the SQL module
cheia.load 'sqlite'

-- Load the cgi module 	
cheia.load 'cgi'

-- Read the submitted data into the 'data' table 	
data = cgi.process() 	

-- Start writing the output page 	
cgi.put_header() 	
print('<html><body>') 	

-- Open the database
db = assert(sqlite.open('/Library/WebServer/SQLiteData/example.db'))

-- Create a Table
error_number, error_message = sqlite.exec(db, "CREATE TABLE 
example_table (fieldA varchar, fieldB varchar)")

-- Insert some data
error_number, error_message = sqlite.exec(db, "INSERT INTO 
example_table (fieldA, fieldB) VALUES ('foo', 'bar')")

-- Select some data
sql = "SELECT * FROM example_table"
vm = sqlite.compile(db, "SELECT * FROM example_table")

print(sqlite.error_string(error_number))

sqlite.close(db)
--Apple-Mail-1-945559749
Content-Transfer-Encoding: 7bit
Content-Type: text/enriched;
	charset=US-ASCII

I'm trying to get sqlite to work with a cgi script in Lua.


When I call SELECT Lua returns an unknown error.  


Does anyone have a working example of using the sqlite module with cgi
they can share?


Thanks in advance,


-joe-


Example code of my problem:


<fixed>#!/usr/local/bin/luacheia5 	


-- Load the SQL module

cheia.load 'sqlite'


-- Load the cgi module 	

cheia.load 'cgi'

 

-- Read the submitted data into the 'data' table 	

data = cgi.process() 	


-- Start writing the output page 	

cgi.put_header() 	

print('<<html><<body>') 	


-- Open the database

db = assert(sqlite.open('/Library/WebServer/SQLiteData/example.db'))


-- Create a Table

error_number, error_message = sqlite.exec(db, "CREATE TABLE
example_table (fieldA varchar, fieldB varchar)")


-- Insert some data

error_number, error_message = sqlite.exec(db, "INSERT INTO
example_table (fieldA, fieldB) VALUES ('foo', 'bar')")


-- Select some data

sql = "SELECT * FROM example_table"

vm = sqlite.compile(db, "SELECT * FROM example_table")


print(sqlite.error_string(error_number))


sqlite.close(db)</fixed>
--Apple-Mail-1-945559749--



-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org