Hi, Drupal community.

I am looking for about this question.
I have found, modules and other answers. But i don't understand how to do it finally.

The question is very simple:
I have working Drupal 7 and all is correct.
Now, I want to show (or import) several external tables of sql (or .csv) to the drupal site.

I mean: I want to have several drupal views, with diferent shows of the external tables.

The problem is that external tables have not the same structure than the sqltables of drupal. Maybe, i will use a field of the external table to make a relation with a field data of the drupal sql. Only one...

How can i do that? It is possible?

Thank you. And sorry if the answer is in drupal forums yet.

Regards!!

Comments

silypointer’s picture

1. Connect to DB
2. Fetch all records
3. Loop through each of them and use that array to create table using Drupal Table API
4. From field array you can get the field column name and create header
5. Create data row in table
6. Print that table using form api

Same steps for CSV except, instead of connecting, you will have to open CSV read data from it and then process it

Other solution could be to push the outer data to Drupal database and play with it.
This comes with the limitation that you will have to push the every time if the outer tables gets updated

Thanks!

jorge_vicente’s picture

Thank you.

I'll try this. I will answer when I check if it worked.

Regards and thank you again.

zeezhao’s picture

If you've not seen these:
- patch using the data module: https://www.drupal.org/node/864184
- https://www.drupal.org/project/feeds_sql

I have not tried both myself but sounds interesting.

jorge_vicente’s picture

Thank you too!!

I will try too and I come back with a feedback!!

Regards!

jorge_vicente’s picture

Hi,

I think that it is the best idea.

Now, i am testing this. And i will come back with the answer, that if it works or not.
Thank you, and regards

jorge_vicente’s picture

Hi!!

Finally I had using ONLY one module: "Feeds SQL", because I am putting this SQL table, in the same schema of Drupal.

The steps are:
- You create a "content type".
- You create a "feed import". From the table that you want (SELECT * FROM 'table', 'schema')
- You put the "target" of the content (the "content type" where you want to put the new data)
- You use "mapping" to link the source data to target data. (Source Field to Target Field)
- You can specify the "nodes references" in this fields.
- Finally, you save, and Drupal add (or remove, or modify) this "content type" with the new data.

In addition, with "job scheduler" you can program every x time, to do this action. I mean you can say to Drupal, that execute this "feed import", every day, every 30 minutes, ...

I have tested this with a .csv file, and it works on the good same way.

Thank you to all for the help.
Regards!!

msimanga’s picture

Have a look at the Forena Reports. This should more than meet your requirement.

Pierre.Vriens’s picture

+1 for this recommendation ... Make sure to also look at the community documentation (eg the various demo videos, the charting features, etc). After installing forena, you'll also have access to all sorts of tutorials that come with it.

jorge_vicente’s picture

Thank you @msimanga and @Pierre.Vriens.

I have been testing "Forena Reports", and it is awesome. But It is not that I need... (Or i don't know how to use this on the good way).
I mean: It is a good module to do a lot of things with the data that you have. But not to bring external tables or .csv files.

Thank you anyway.

Regards!!!

Pierre.Vriens’s picture

Jorge, reviewing the "documentation" (= help reports) that comes with forena (after you installed the module), and looking at the video tutorials is the best approach to ensure that you know how to use forena.

Would you mind explaining what "you" mean by "external tables"? Like which RDBMS is it? And also what you think Forena is missing to meet your requirements?

jorge_vicente’s picture

Hi Pierre, I will try to explain that I need.

I have a "content type", with a specific fields where I introduce new data. And you can introduce data in this "content type" manually.

But I need to bring with "feed importer module"(i am trying with this module now) of an external table (in the same schema or another schema) or of a .csv. This external data will have the same fields with the same format that the "content type" of Drupal.
I need that Drupal brings this data and will make this "content type" itself.

I mean: If I bring a .csv with 5 lines (it must be the same if i write 5 times the content type manually).

The thing is.. It is not only to show a grid, table or HTML table. I need that the external content enter to stay in the format of drupal.

And my idea is to bring this data every week, by example.

Thank you Pierre. At the moment i am trying "feed importer module".
Tomorrow i will confirm if it works.

Regards

Pierre.Vriens’s picture

Jorge, talking about feeds: have you seen the video about Forena and Feeds ? If so, how does that approach compare (or differ) from what you're trying to achieve?

jorge_vicente’s picture

Hi Pierre,

I have seen the video and they are using Forena with "Feed imports".

Finally I will use the "Feeds SQL, that @zeezhao had told me.

Thank you again for the help.

Forena has a lot of posibilites that I am sure that i will use in a future.

Regards!!