Our Run BASIC + SQLite integration is coming along nicely, and it lays the groundwork for using other databases later on (Oracle, SQL Server, MySql, etc.). One thing that we did to make using databases handy is that we built in some display technologies. You can query the database and then just use the RENDER statement to put the result on the web page. You can also inject some CSS styling right into that result, and you can even turn the line items of any column in the displayed table into links.
We also have added an httpget$() function so you can use HTTP to retrieve web documents like web pages, RSS feeds, etc. We plan to include an XML parser, and if we can come up with an easy to use way to stream through an HTML document we will provide that also.
These capabilities (except for the table rendering) will also be included in Liberty BASIC v5.0.
To keep up with what we're doing with Run BASIC, make sure to visit this blog and also http://libertybasic.conforums.com/index.cgi?board=runbasic
Showing posts with label oracle. Show all posts
Showing posts with label oracle. Show all posts
Saturday, July 07, 2007
Wednesday, June 27, 2007
Adding SQLite to Run BASIC
Here is some example code that runs under Run BASIC using SQLite v3.4. I haven't pushed this stuff onto the publicly hosted site. SQLite will come with the Run BASIC personal server and should be suitable for many projects. Support for other databases like Oracle, PostgreSQL, SQL Server, etc. will be added with the professional server license.
SQLite is a popular database engine provided as a library and is supported for Windows, Mac and Linux. The source code is available and is in the public domain so it is completely free. We will support the parts of Run BASIC that integrate with SQLite, but as for the specific level of conformance to the SQL standard and other technical details, see http://www.sqlite.org/
The SQLITECONNECT #obj, "databasefile.db" statement connects to a database and sets the #obj variable to be a connection object. The connection object understands EXECUTE(), HASANSWER(), NEXTROW$() and DISCONNECT(). I'm sure there will be more commands.
Notice the NEXTROW$() method. It returns each query result row as a string, with each item delimited by the specified string ("," in the example but it could be CHR$(9) or something else). It is trivial then to use the WORD$() function to extract the information. We will certainly also add the ability to get items by name.
sqliteconnect #users, "test.db"
call execAndPrint "select * from users"
call execAndPrint "select count(*) from users"
#users disconnect()
end
sub execAndPrint query$
#users execute(query$)
while #users hasanswer()
result$ = #users nextrow$(",")
print result$
wend
end sub
SQLite is a popular database engine provided as a library and is supported for Windows, Mac and Linux. The source code is available and is in the public domain so it is completely free. We will support the parts of Run BASIC that integrate with SQLite, but as for the specific level of conformance to the SQL standard and other technical details, see http://www.sqlite.org/
The SQLITECONNECT #obj, "databasefile.db" statement connects to a database and sets the #obj variable to be a connection object. The connection object understands EXECUTE(), HASANSWER(), NEXTROW$() and DISCONNECT(). I'm sure there will be more commands.
Notice the NEXTROW$() method. It returns each query result row as a string, with each item delimited by the specified string ("," in the example but it could be CHR$(9) or something else). It is trivial then to use the WORD$() function to extract the information. We will certainly also add the ability to get items by name.
Subscribe to:
Posts (Atom)