问题描述
我需要使用.accdb数据库,并且需要将其导入PostgreSQL.我相信这将是一个简单直接的问题(我希望它已经解决了),但是一个简单的解决方案使我无所适从.
I need to use an .accdb database, and to do that it needs to be imported into PostgreSQL. I believe this would be a simple and straightforward problem (I expected it had been already solved), but a simple solution escapes me.
我要补充一点,我无权访问Access(lol),我的解决方案在很大程度上依赖于此.如果那不可能,我可以去找一个有访问权限的人,让他们将每个表转换为.csv或类似的文件.
I'll add that I don't have access to Access (lol), and my solution is loosely dependant on that. If thats impossible I can go find someone with access and get them to convert each table to .csv's or something like that.
推荐答案
您不需要在计算机上安装MS Access即可从Access数据库引擎文件中读取数据.
You don’t need MS Access installed on a computer to read data out of an Access Database Engine file.
自Windows 2000附带Access数据库引擎以来的所有Windows副本;但是,这将是Jet 4.0引擎,并且您将需要ACE(2007)引擎的组件.幸运的是,它可以从Microsoft的 2007 Office System驱动程序:数据连接组件.
All copies of windows since windows 2000 ships with the Access Database Engine; however this will be the Jet 4.0 engine and you will need the components for the ACE (2007) engine. Happily, it is available for download from Microsoft as 2007 Office System Driver: Data Connectivity Components.
任何支持com对象的编程语言都将使您无需安装MS Access即可提取数据.您甚至可以在此处使用Windows脚本,甚至不用在Windows框中安装任何软件.
Any programming language that supports com objects will left you lift out data without having MS Access installed. You can even use windows scripting here and not even install ANY software on your windows box.
以下代码适用于Access数据库引擎的Jet mdb版本,但是您可以使用ACEDAO使其适应您的需求:
The following code is for the Jet mdb version of the Access Database Engine but you may be able to adapt it for your needs using ACEDAO:
Set dbEng = CreateObject("DAO.DBEngine.36")
strMdbFile = "C:\Documents and Settings\" & _
"Albert\My Documents\Access\" & _
"ScriptExample\MultiSelect.mdb"
Set db = dbEng.OpenDatabase(strMdbFile)
strQuery = "select * from contacts"
Set rs = db.OpenRecordset(strQuery)
rs.MoveFirst
If rs.EOF = True Then
Quit
End If
strTextOut = "C:\t5.txt"
Set fs = Wscript.CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(strTextOut, 2, True)
'2 = write, 1 = read
Do While rs.EOF = False
strOutText = rs("LastName")
ts.Writeline strOutText
rs.MoveNext
Loop
ts.Close
rs.Close
但是,实际上,如果这是一次导出,那么找到具有MS Access副本的人将使这项工作减少,但是您可以读取访问文件而无需安装任何软件.实际上,如上所述,即使是初次安装Windows,也可以使用上面的Windows脚本文件,该文件也可以在没有安装任何软件的情况下运行.
However, really, if this is one time export, then finding someone with a copy of MS Access will make this less work, but you CAN read a access file without having to install ANY software. In fact, as noted above, even a virgin install of windows would allow you to use the above windows script file which also can be run without any software having been installed on the windows box.
这篇关于如何将accdb转换为Postgres数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!