通过 PHP 或其他脚本将 Corel Paradox 4.0 Tables 批量转换为 CSV/SQL
最近,我开始研究如何将大约 16k Corel Paradox 4.0 数据库表(我的客户主要由于大量后勤事务而使用旧平台 20 多年)转换为更现代的格式(即 CSV、SQL 等)到目前为止,我一直在研究 PHP,因为它有一个专门用于 Paradox 数据处理的库,但是我对如何编写转换代码相当有信心(即简单地调用一些文件打开、关闭和写入函数)我担心错误检测并确保在运行脚本时,我不会花费数小时等待它运行,只是为了看到导出的 16k 损坏文件。
另外,我不完全确定调用文件的逻辑循环。我正在考虑让程序生成具有适当扩展名的所有文件的列表,然后循环遍历该列表,但是我不确定这是否适合这种大小的目录。
这是在具有 XAMPP 设置的本地 Windows 7 x64 系统上运行(数据库全部是内部使用),所以我不确定纯 PHP 是否是最好的主意 - 所以我一直想知道 Python 或其他一些轻量级脚本是否是语言可能更适合处理这个问题。
预先非常感谢您的任何见解和帮助,
Recently I've begun working on exploring ways to convert about 16k Corel Paradox 4.0 database tables (my client has been using a legacy platform over 20 years mainly due to massive logistical matters) to more modern formats (i.e.CSV, SQL, etc.) en mass and so far I've been looking at PHP since it has a library devoted to Paradox data processing however while I'm fairly confident in how to write the conversion code (i.e. simply calling a few file open, close, and write functions) I'm concerned about error detection and ensuring that when running the script, I don't spend hours waiting for it to run only to see 16k corrupt files exported.
Also, I'm not fully sure about the logic loop for calling the files. I'm thinking of having the program generate a list of all the files with the appropriate extension and then looping through the list, however I'm not sure if that's ideal for a directory of this size.
This is being run on a local Windows 7 x64 system with XAMPP setup (the database is all internal use) so I'm not sure if pure PHP is the best idea -- so I've been wondering if Python or some other lightweight scripting language might be better for handling this.
Thanks very much in advance for any insights and assistance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这无疑为时已晚,无法为您提供帮助,但对于后代...
如果拥有 Corel Paradox 工作环境,则可以使用它来轻松过渡。
我们将拥有的 Corel Paradox 9 表移动到我们通过连接到架构(使用诸如 SCHEMA001 等别名)构建的 Oracle 架构中,然后从 Paradox 内部的脚本中编写此过程:
Proc writeTable(targetTable String)
错误陷阱警告(是)
尝试
tc.open(目标表)
tc.copy(":SCHEMA001:" + targetTable)
tc.close()
失败时
错误显示()
结束尝试
endProc
人们可以通过更多的 Paradox 编程来高度改进这一点,但你明白了。不过,我们发现的一件事是,Paradox 在创建 Oracle 版本时对列名称使用双引号,这意味着您可以在 Oracle 中的列名称中使用小写字母,这是一种痛苦。我们通过向 upper() 所有结果列名编写一个快速 Oracle 查询来纠正这个问题。
我们这样调用该过程:
Var
目标表字符串
TC 光标
endVar
方法运行(var eventInfo Event)
目标表 = "某个表名称"
写表(目标表)
msgInfo("TransferData.ssl--脚本完成",
“就这些了,各位!” )
返回
结束方法
This is doubtless far too late to help you, but for posterity...
If one has a Corel Paradox working environment, one can just use it to ease the transition.
We moved the Corel Paradox 9 tables we had into an Oracle schema we built by connecting to the schema (using an alias such as SCHEMA001) then writing this Procedure in a script from inside Paradox:
Proc writeTable(targetTable String)
errorTrapOnWarnings(Yes)
try
tc.open(targetTable)
tc.copy(":SCHEMA001:" + targetTable)
tc.close()
onFail
errorShow()
endTry
endProc
One could highly refine this with more Paradox programming, but you get the idea. One thing we discovered, though, is that Paradox uses double quotes for the column names when it creates the Oracle version, which means you can get lower-case letters in column names in Oracle, which is a pain. We corrected that by writing a quick Oracle query to upper() all the resulting column names.
We called the procedure like so:
Var
targetTable String
tc TCursor
endVar
method run(var eventInfo Event)
targetTable = "SomeTableName"
writeTable(targetTable)
msgInfo("TransferData.ssl--script finished",
"That's all, folks!" )
return
endMethod
如果您打算只转换数据,我猜这是一个过程,您只需将脚本作为命令脚本在本地运行一次即可。为此,您不需要网站,因此也不需要 XAMPP。你采用什么语言是次要的,除非你说 PHP 有一个库。 python或其他有吗?
关于您对错误检测的担忧,为什么不首先仅使用一个文件测试您的脚本。如果转换成功,您可以构建循环并在可能五个文件上进行测试,即有一个计数器在该数字之后结束该过程。没关系,你可以继续剩下的。您还可以写入日志数据并转储每处理 100 个文件的结果。通过这种方式,您可以查看脚本是否正在执行某些操作或处于空闲状态。
If you intend to just convert the data which I guess is a process you do only once you will run the script locally as a command script. For that you don't need a web site and thus XAMPP. What language you take is secondary except you say that PHP has a library. Does python or others have one?
About your concern of error detection why not test your script with only one file first. If that conversion is successful you can build your loop and test this on maybe five files, i.e. have a counter that ends the process after that number. It that is still okay you can go on with the rest. You can also write log data and dump a result for every 100 files processed. This way you can see if your script is doing something or idling.