Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get at the database schema of a hidden DB?

My customer is a dental practice that has bought a piece of practice management software. This software was installed on their local server, including a patient database, a schedule and all manner of medical records. Now they want me to write some utilities for them that aren't provided with their package, and for this I need the ability to query this database.

I tried calling tech support of the software manufacturers (Patterson/EagleSoft), and it's difficult finding anyone who understands the technology enough to answer my questions. As far as I can tell, there's no API for their software, and understandably they're reluctant to tell me how to query the DB directly, programmatically. They do have an interactive query window, but obviously that's no good for writing automated queries. All that they would let on is that somewhere there's a SQL Server DB, but the ODBC drivers to connect to it are SQL Anywhere drivers (huh?).

So I searched around on the server and couldn't find any database files. Then I discovered that the installation creates some kind of proprietary virtual machine, which is only visible to the EagleSoft software. But while they've been very good at insulating their DB in layers of obfuscation, they have left open an ODBC driver, which is indeed an SQL Anywhere connection.

Now after that fascinating and lengthy preamble, here is my question: What queries can I run over this ODBC connection to interrogate the DB as to its structure? If it's a SQL Server DB underneath I could use the sysobjects table, but I don't fully grasp how you can use a SQL Anywhere ODBC connection to connect to a MSSQL DB. And If they were misinforming me and it really is a SQL Anywhere DB underneath, what are the queries to run to get at the DB structure?

And if there's anyone else out there who's ever succeeded in actually querying EagleSoft (or any similar proprietary package) - please tell me how you did it!

like image 728
Shaul Behr Avatar asked Dec 12 '10 09:12

Shaul Behr


People also ask

How do I find the schema of a database?

You can get a list of the schemas using an SSMS or T-SQL query. To do this in SSMS, you would connect to the SQL instance, expand the SQL database and view the schemas under the security folder. Alternatively, you could use the sys. schemas to get a list of database schemas and their respective owners.

How do I view schemas?

To show the schema, we can use the DESC command. This gives the description about the table structure. The following is the syntax. DESCRIBE yourDatabasename.


2 Answers

Turns out the simplest way to do it was to write a little app using OdbcDbConnection, and connect using the DSN installed with the software. It took one probing 'select * from sysobjects' to reveal that it is, indeed a MS-SQL database underneath all that, and I'm good to go from there!

like image 126
Shaul Behr Avatar answered Oct 06 '22 14:10

Shaul Behr


I'd use a tool like squirel which is great at browsing any database to check if anyone was successful with "SQL Anywhere" this google result:

http://blog.gmane.org/gmane.comp.db.squirrel-sql.users/month=20091001

Shows that others have managed to get squirrel to do this. It's quite easy to use... assuming of course you manage to get the connection working!

like image 26
Quaternion Avatar answered Oct 06 '22 12:10

Quaternion