Creating A Database Object

A Database object is where SQL Yoga stores all of the information about your database that is used to automate the creation of SQL queries for you.

Let's look at how to create a Database object.

Note: The SQL Yoga distribution includes a Revolution IDE plugin that is helpful during development. To learn more about the plugin please visit the plugin manual.

 

Note: The examples used in these tutorials will use the default values for many of the parameters passed into the SQL Yoga handlers. In cases where you are only using one Database object (most cases) there is no need to pass parameters to a command like dbobject_createObject. If you plan on using multiple Database objects make sure you read the API documentation so you understand what the parameters are.

1) Create a Database Object

1) Create a Database Object

You can use dbobject_createObject to create a new database object in memory.

This code only needs to be run once so you can execute it in the message box if you would like.

==========

Copy & Paste

==========

dbobject_createObject

put the result

Now a new Database object exists in memory. The name of the Database object is default.

Note: SQL Yoga will throw an error if a Database object named default already exists.

11 Comments

Dion McCormick

Can you supply an example of ODBC. Using SQL Server with my system.

Trevor DeVore

Once I set up ODBC in the unit tests I will. I have coded the ODBC support for connecting but I haven't set up a test environment for it yet.

Dion McCormick

Thank you. Keep me posted! p.s. Great product...needed for the runrev development environment.

Trevor DeVore

I've added ODBC instructions to this lesson and updated SQL Yoga to support it. So far the only test that fails is when inserting binary data. You can get the latest SQL Yoga version from the SQL Yoga page: http://www.bluemangolearning.com/revolution/software/libraries/sql-yoga/

Dion McCormick

Thanks for the update. If I am using SQL Server as my back end....what do you suggest as the best method for reading the structure of the database before moving onto ODBC.

Trevor DeVore

Hmm, I have no idea :-) I'm having trouble getting database schema information when using the ODBC driver. I will do some more research and see what I can come up with.

Trevor DeVore

@Dion - actually I think ODBC does in fact work. I was traveling and using an unlicensed ODBC driver that only returned 3 records which led to my incorrect assumption that schema reading with ODBC wasn't working. Just try connecting directly to the database using the ODBC example (name connection "development" not "development_odbc" and see if MS SQL works for you. I don't have a MS SQL server to test with yet unfortunately.

Trevor DeVore

Actually there is one last thing I need to do and that is write the calls for MS SQL server that will read in the schema. So hold off just a little while longer.

Dion McCormick

Cool. Good idea. I don't have any immedaite deadlines. Just very excited about your product. Will save me a ton of time building the tools I want to build around my database!

Dion McCormick

Just checking in on the status of this. I know you were busy with RunRev event lately. Keep me posted!

Trevor DeVore

Just uploaded 1.0.0 build 5 and SQL Server over ODBC passes all the SQL Yoga unit tests.

http://www.bluemangolearning.com/revolution/software/libraries/sql-yoga/

Let me know how it works for you in the forums:

http://www.bluemangolearning.com/forums/viewforum.php?id=15

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.