- App Store
Write data on DBF using Scripts in xTuple
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?
Wed, 03/06/2013 - 08:03#1
I'm not sure how a custom
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.
Wed, 03/06/2013 - 08:21#2
What kind of DBF file?
What kind of DBF file? What's your context?
Wed, 03/06/2013 - 13:05#3
DBF's are old FoxPro or older
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.
Wed, 03/06/2013 - 13:28#4
I was also lucky enough to be
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
DbfModel(const QString &path = QString(), const char *encoding = "IBM 850", QObject *parent = 0);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
void setTable(const QString &tableName);
virtual bool select(void);
QModelIndex indexForValue(QString key, int column = 0);
QList<QModelIndex> indexesForValue(QString key, int column = 0);
QMap<int, QString> horizontalHeaderData;
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.
Mon, 03/18/2013 - 10:19#5
I have had great success
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.