mountainx Posted June 4, 2020 Posted June 4, 2020 (edited) I am trying to import data from a MySQL database and need to somehow also import fieldnames to be the fieldname in FMP. Is there anyway to do that? I have a CSV of the fieldnames and I also have a MySQL dump of fieldnames and associated data. Thanks for any help. Edited June 4, 2020 by mountainx
comment Posted June 4, 2020 Posted June 4, 2020 If you have a .csv file that contains field names in the first row and data in the other rows, you can import it into a new table and designate the first row to be used as the source for field names in the new table.
mountainx Posted June 4, 2020 Author Posted June 4, 2020 What about an existing table? If I deleted the old fields that corresponded to "last year's data", can I append the fields to an already existing table?
comment Posted June 4, 2020 Posted June 4, 2020 No. If you need a new set of fields for each year, you are doing something wrong.
mountainx Posted June 4, 2020 Author Posted June 4, 2020 Well actually, we use this database once a year for a yearly survey so the fieldnames in the survey each year are unique - survey_numberXgroup_numberXquestion_number. So last year's data has absolutely no relevance and get deleted. It may be wrong, but it is the way it was designed. IS that still a no?
comment Posted June 4, 2020 Posted June 4, 2020 3 minutes ago, mountainx said: the fieldnames in the survey each year are unique It makes no difference. Adding data to a table should not require a change in schema. You should have a permanent set of fields that includes a field to store the year, if necessary. In any case, it is not possible to change a table's schema programmatically. At least not from within Filemaker (it may be possible using a third-party application that connects to Filemaker via ODBC or JDBC).
gczychi Posted August 14, 2020 Posted August 14, 2020 Hi, hope it’s not to late to answer. It really seems to make no sense to have new field names each year for the same kind of data. If you can somehow create fields that you can reuse each year, then the following would be my suggestion: Since you seem to know SQL, I would suggest FileMaker’s Execute SQL function. With a free plugin (SQL Runner from Dracoventions; super great product, btw.) you can do INSERT INTO as you wish. The steps would be: 1) Paste SQL DUMP into a text field. 2) In a script, read line after line of the text field and put the data of each line into $Variables. 3) Using the Execute SQL script step you can easily INSERT INTO the lines into your FileMaker data base. Hope this helps, Gary
Recommended Posts
This topic is 1828 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now