Sunday, August 29, 2010

jquery.rdbhost.com is out there.


Javascript programmers dodging that whole server-side programming thing are a market for us.

Unfortunately, until now, a JS programmer wanting to query Rdbhost databases has had to write there own low-level javascript ajax code, and do the domain pointer management...  I don't think anybody actually did all that.

Now, there is a module that makes accessing an Rdbhost.com database from your server easy.  You still have to set up a subdomain for your domain, to point at our server, but after that it is pretty straightforward.

A page snippet might look like:
<script>
  $.ready( function () { 
    $.rdbhostConfig( { 'userName' : 's0000000002',
                       'authcode' : '-'   } );  
    $('table#big_cities').populateTable(
         'SELECT * FROM cities WHERE population > 10000000');
         // no pun intended
  };
</script>;
The library

Wednesday, August 11, 2010

New RdbAdmin Features

As I mentioned a couple days ago, the Rdbadmin application has been revised.  The general goals of the revision was to make the app more maintainable and remove a few bugs.

Specific goals were:

  1. Access the host server via the new Rdb.js module, instead of $.ajax and custom code.
  2. Make the application portable, so that it can be loaded from other servers under other domain names.
  3. Move all html out of the javascript modules into the html host page itself.  This makes a css 'skin' designer's job easier, as all the html elements are there in the page to see.
  4. Move all the javascript out of the html host page, and into javascript files.
  5. All javascript is to conform to jslint expectations.
  6. Minimize the number of globals. The former version included a global object for each form and a few more, with references to those globals scattered all over.
These were all accomplished, with exceptions here and there.  There is still a smidgen of login and initialization code in-line in the html file, and the javascript files still have some $('<option>') elements  here and there, so the html/js separation is not pristine.  JSlint compliance was with a custom configuration, not the default.

In addition to the above items, an additional couple of features  wer added:

The table structure page now includes, in addition to the table columns and indexes, a list of constraints.  There is a new form to add or drop constraints for a table.  I also removed the 'primary key' and 'unique' columns from the table edit, as those constraints will be handled by the Constraints form.  Eventually, they will be added back in.

Also, each form now features an SQL display box.  As the form is filled in, the app continuously generates and displays the SQL that will perform the desired action.  When filling in a create table form, for example, the SQL box will display the 'CREATE TABLE tablename...' code that will be sent to the server to generate the table.  This might be useful to new programmers to understand how SQL syntax goes, and might help experienced programmers understand what, exactly, the form is doing.

Most forms include an 'Edit SQL' button, which will load the displayed SQL into the SQL editor for refinement and submission to the server.  The PostgreSQL syntax for various operations, such as creating tables, is more capable and feature-rich than the RdbAdmin interface, so for some less common requirements, you might need to drop to the SQL editor to get what you need.

There is a login page now, if none of the automated login approaches work.   The app can be loaded with a non-authenticated role in the URL, and that role will be used for the database connection, otherwise it presents a login app, for entry of email and password.  When the app is loaded from Rdbhost itself, a cookie-based login is attempted, for users that have already logged in to Rdbhost itself.

The code is at: http://www.rdbhost.com/downloads/rdbadmin-0.8.zip
The latest code will always be available from subversion, at: http://www.assembla.com/code/rdbadmin/subversion/nodes

Monday, August 9, 2010

RdbAdmin, free at last!

The Rdbadmin database administration has a couple of purposes.

Firstly, of course, it is a tool for administering Rdbhost databases.  As an online application, it is available to all accounts immediately, without installing anything. 

Secondly, it is an example of what can be done from Javascript to manipulate online databases.  We could have done a server-side admin script, ala PhpMysqlAdmin, but that might seem like an expression of no faith in the Rdbhost design.  If we are presenting the host as a do-anything-from-Javascript database host, shouldn't we walk the walk, and implement database tools in Javascript ourselves?

Rdbadmin has, thus, always been a Javascript application, and source code has been available for the borrowing.  However, before now, it did not run on any server other than the rdbhost.com server, due to Javascript cross-site-scripting protections.  That is about to change:  I have been, over the last month, rewriting the Rdbadmin app to use the Rdb.js interface module, which makes it portable.  By mid-week, you will be able to check-out from subversion a version that works hosted on any* server, to access databases hosted on Rdbhost.  You will then have a working admin script on your server, subject to your evolutionary refinements, or to just borrow working code from for your own Rdbhost-based projects.


The Rdb.js module itself will be properly released this week as well, with documentation.  It is available now, on github, but lacks documentation, and is still kindof crufty with dead code.



* The Javascript cross-site-scripting constraints have not gone away, so you will need to be able to create (and point offsite) a new subdomain for your host server; a how-to will be in the release package.  We are also working on a CORS based approach, but that has its own limitations.