Whilst the SQLite capability of this access is powerful, it is by its very nature “local”. So I became interested to see if I could use OLE to access a “remote” database.
Since I did not have access to any remote databases I decide to install a full database service application, specifically I downloaded and installed the MAMP package for Windows, backed-up my www.ripe.com web site and loaded the back-up site to the MAMP installation on my PC.
This gave me a database that I could access as if it were remote, except it was at 127.0.0.0 i.e. hosted locally.
Here is a script that I used to:
- connect to the database
- run a query on a remote table
- create a local (SQLite) copy of the remote table
newscriptdbclosedbopen ("memory")dim dbCON = createobject ("ADODB.Connection")dim dbRS = CreateObject("ADODB.Recordset")dim myItemdbCON.ConnectionString = "DRIVER={MySQL ODBC 8.0 ANSI Driver};SERVER=localhost;UID=root;PWD=root;DATABASE=wordpress;OPTION=3"dbCON.Open ()dbRS .open ( "select * from wp_options ", dbCON )
dim index = 0freestring = " create table myTable ( "FOR EACH myItem in dbRS.fieldsIF ( index ) thenfreestring = freestring & " , "END Ifindex = 1 freestring = freestring & sqlIdentifier(myItem.name) & " text"NEXT myItem freestring = freestring & " ) "sql = freestringDO while ! dbrs.EOFindex = 0freestring = "INSERT into myTable values ( "FOR EACH myItem in dbRS.fieldsIF ( index ) thenfreestring = freestring & " , "END Ifindex = index+ 1
freestring = freestring & sqlString ( (myItem.value) ) NEXT myItem freestring = freestring & " ) "
sql = freestringdbRS.movenextLOOPdbRS.close