Write data on DBF using Scripts in xTuple
Hi,
I am integrating xTuple to a DBF file and I need to insert data from xTuple database going to the DBF file. How can I do this using the Custom Screen and Scripts?
I'm not sure how a custom screen and script would do this for you without first getting in to the SQL. You may want to look at the API shema in the xTuple database and start from there.
What kind of DBF file? What's your context?
Shane
DBF's are old FoxPro or older dBase files - coming from the old SBT channel have lots of background with that - but you're not going to have much luck writing / reading directly to / from that file via scripting in Xtuple/QT Script.
If you've got a running Foxpro system, exporting & importing csv files is trivial to do. That's probably going to be your only path - intermediate csv files.
To handle dbf's you'll need some sort of library to load that handles that part - I know there's a few Python libs around of various quality - but I'd be highly surprised at this point if there was such a beast for QT script.
I was also lucky enough to be in the same situation (not!), that is, having to read data *online* from a legacy system that uses DBF files.
I tried a couple of Python DBF libraries, but most of them were not capable enough (I remember all of them failing to read memo fields/files).
Then, I tried "xbase64", an Open Source library that is very capable. On top of that, I wrote a "DbfModel" for Qt, something along these lines:
class DbfModel : public QAbstractTableModel
Having a model means a Qt application can use that data natively in a lot of widgets. You could do something similar, but for xTuple that means modifying the GUI client.
That, again, makes me dream of having a supported plugin architecture in the GUI client.
I have had great success reading DBF's (including memo fields) using python. You have at least two choices pyodbc, and pydbf. If you are using windows both work well. pydbf is easier to work with but pyodbc allows more stuff including using the indexes.
Johnf







