Hello,

i'm writing a custom script to import some data into my drupal installation.

The problem is that i need to import also images and attachments, so i have to take care of the nodes table, of the fields_* tables, and of the files_* tables... and i'm afraid that i'll forget something.

Is there some documentation that can help me to manually insert an attachment to a node by editing the database?

Thanks!

Comments

lomo’s picture

It's probably best to just let the node/add/node_type and related field modules, etc, deal with everything, rather than attempting to reinvent the wheel to import data. That said there are two possible approaches:

1) Migrate module. If this works for your content.
2) Script a loop that creates Selenium IDE code. I've actually done this and was considering creating a new project here to add some of my abstracted "basics" functions and, perhaps, a full example to provide some basis for others to follow this route. It's not that hard, and is worthwhile if you have hundreds of nodes worth of content (or a lot, anyway) and data already in a spreadsheet format.

See you at the Drupalcon!

Sifro’s picture

Hi, thanks for your reply. I have no idea of what Selenium IDE is, so i bet option #2 is not a good option for me...

I had a look at the Migrate module... that looks pretty complex, but may be worth it. I'll start studying it... by the way, what do you mean by "if this works for your content"? What could be its limitation for my case?

lomo’s picture

Depending on the type of "custom script" you were writing, Selenium IDE might not be that hard to work with. You would just need to record the process using the "IDE" and then take the output (basically just HTML table code) and put it into functions with variables replacing the input... well, it's not that hard. If you've never heard of Selenium IDE, you might still want to try it out since it can be useful for a number of tasks in Drupal-related projects. At least I've been able to do just about anything I could do manually.

I don't know what might not work for you with Migrate, but the last time I tried to use it, it couldn't do everything I needed, which meant that it was interesting and potentially useful, but not much use to me. But that was long enough ago that I'm not qualified to speak about limitations of Migrate.

Best of luck, with whatever method(s) you end up using.

See you at the Drupalcon!

Sifro’s picture

I ended up using the node_export module... it had some bugs, but they are being fixed, and with a few workarounds, the process went smoothly.