Rev and Databases - getting started
Trevor DeVore
trevor at mangomultimedia.com
Thu Aug 22 11:52:01 EDT 2002
>While the docs do a decent job of explaining how to work with a
>Valentina or MySQL database, there is as far as I can tell no help at
>all with getting started on that process. For example, I open the
>Database Manager from the Tools menu and Valentina as the database
>type. Now it wants a host and a database, but nothing in the Help
>tells me anything about either of these two values.
For Valentina your host would be blank and the database would contain the full path to the Valentina database - Macintosh HD:Users:you:projects:db:mydb.vdb. For MySQL the Host would be "localhost", the Database would be the name of your database, the User would be root if you haven't added any users, etc. since installing MySQL. The password is either blank or whatever password you set up for the user you are connecting with.
>
>I'm on OS X and I know I have mySQL installed, too, though I haven't
>yet completely figured out how to use it (I'm studying that now). But
>even assuming I dope it out in the Terminal and/or Python, I still
>have no clue how Database Manager or RR scripts would go about
>providing a host and database name.
>
>Can someone point me in the right direction, more or less?
I haven't played with MySQL yet but I do have Valentina mostly working (except that when I compile the program the program dies whenever I try to connect to the database, but that is another story).
What I have done in order to keep things clean is a create a stack with all my database code in it. You cold just as easily do the same thing with an object in your stack and then insert the objects script into the message path using insert script. I then start using this stack in the program I want access to it using this code:
put "DBLibrary,DBLibrary.rev" into newStackFiles
set the stackFiles of this stack to newStackFiles
I have setup all the correction parameters as custom properties of the stack so I can change the parameters using the custom props.
I have a DB_Connect function which has the following code in it:
put the filename of this stack into stackPath -- this is the path of the stack this is used in
set the itemdelimiter to "/"
delete last item of stackPath
put "/" after stackPath
if the platform contains "Mac" then
put revMacFromUnixPath (stackPath & the dbName of me) into osDBPath
set the connectionID of me to revdb_connect(the dbType of me, \
the dbHost of me, osDBPath, the dbUserName of me, \
the dbPassword of me, the valentinaCacheSize of me, \
the valentinaMacSerial of me, "")
else
set the connectionID of me to revdb_connect (the dbType of me, \
the dbHost of me, stackPath & the dbName of me, the dbUserName of me, \
the dbPassword of me, the valentinaCacheSize of me, \
"", the valentinaWinSerial of me)
end if
The custom props for the stack might have the following values
dbType = Valentina
dbHost =
dbName = mydb.vdb
dbUserName =
dbPassword =
valentinaCacheSize = 3*1024
valentinaMacSerial = YourMacSerial
valentinaWinSerial = YouWinSerial
So basically you get the full path to the Valentina database. Mine is in the same directory as the stack so I just get the stack path and append the name of the db to it. For mac you have to convert to a Mac style path for Valentina to work. The custom prop connectionID is set to the id of the connection that is made or has a nice error message for you to deal with. I use this connection id for all the other queries that my db library does. From here you can just execute queries using query, execute and query_blob.
Hope this helps. If this wasn't what you were after let me know.
Trevor DeVore
Blue Mango Multimedia
trevor at mangomultimedia.com
More information about the use-livecode
mailing list