问题
I am working with some data I obtained that is read with a program using an embedded Advantage Database Server. The program was not written by me and does not have all of the functionality that I need. I would like to convert this data to a different format so that I can work with it more freely, such as MySQL.
I know that Sybase provides some tools for converting a single local database into SQL, which is very nice. This would work fine, except that the authors of this program create a new folder containing a new database for every new document that a users is working with. So there could be 100s of separate database folders each with 100s of .ADT files in them.
I am looking for a way to automate the process of converting these .ADT files and their schema to basically anything else. I've had more luck with almost all the other formats I've had to work with in the past, this one has been most troublesome. I don't need indexes, views, or any of that. I only need to export the tables to another format so that I can process some of the data.
So the solution I'm looking for here is just a way to automate the conversion of a single Advantage Database Server local database to SQL. So I have a folder of .ADT files that represent the database.
I included Ruby and Python in the tags because using one of these scripting languages would be ideal, but any solution would be great.
The route I'm on right now is trying to work with the ODBC drivers, but I'm having trouble and hoped that there was an easier solution.
Thanks!
Chase Gray
回答1:
Advantage has a dbi (Perl) driver you could use to access the tables in their existing ADT format. Also has JDBC and OLE DB drivers. See all of them at http://devzone.advantagedatabase.com/dz/content.aspx?key=20&Release=13
Note that link is to the version 9.1 drivers. You will want to grab a driver that is equal to or older than the Advantage server that is running (unless the client is using the Advantage Local Server, in which case it won't matter).
回答2:
After some asking and searching it seems that there isn't something like what I was looking for.
I spent a little while earlier today putting something together based on the Ruby DBF gem. I'm not finished, but it works like I want it to. I'll have to finish up the tests and add the exporting of SQL, etc. but hopefully somebody else finds this question and can retrieve information from a .ADT file without having to install anything.
Here is the link to the project. It'll be in progress for the rest of the night probably. It's pretty minimal right now, but over time I'll probably add to it.
http://github.com/chasemgray/Ruby-ADT http://chase.ratchetsoftware.com/2010/02/reading-advantage-database-server-files-adt-in-ruby/
Now getting data out should be as simple as this.
require 'adt'
table = ADT::Table.new("test.adt")
table.each do |record|
puts record.name
puts record.email
end
Thanks for your help,
Chase Gray
来源:https://stackoverflow.com/questions/2289519/automate-conversion-of-sybase-adt-files-to-sql