Hello,

I've a intranet website running on a PostGReSQL database. Some data from it have to be copied to the internet website running Drupal & MySQL. Some datas have to be inserted in content type node or term list or they have to update some fileds in nodes. My problem is how to insert these datas correctly into the drupal system ?

Example : I got biographies. I have the 'person' table in postGReSQL, an the 'biography' content type in Drupal.

  1. How to update the person.birthday (PostGreSQL) in the field_biography_birthday (drupal). Am I suppose to only look at the 'content_type_biography' table and update the correct field ?
  2. When a new name if inserted in the PostgreSQL database, I need to pre-create a biography in Drupal. How can my daily script create a 'biograohy' content with only the name and first name ? Do I have only to look at the 'content_type_biography' table, or other tables also, and which ones ?

Thank you :)

Comments

vivek.puri’s picture

if you write a migration script using drupal's api then you wont have to worry about manipulating data tables directly and result will be much more consistent.

twen’s picture

Thank you crystacube for your answer !

What I'm wondering now is where to find the right info in the API. Personnaly find the site a mess of useful infos. Could you maybe help me find any page from the API that could help me insert or update datas from a simple php script ? From the API site (api.drupal.org), I can only look for functions, that I don't even know yet :/ I can't find how to "connect" my php script to the API, and then what function can I use to do the job.

Thanks.

Lanny Heidbreder’s picture

It's my understanding that the place to start is with require_once './includes/bootstrap.inc'. Then you call drupal_bootstrap($phase), where $phase is one of the constants listed on that API page. You can load only a certain amount of Drupal's backend depending on what phase you bootstrap to.

I am only repeating what I read in the Drupal book; for more specific advice you'll need to get help from someone way more advanced than I am. If this forum topic doesn't pan out, try #drupal on irc.freenode.net . :)

vivek.puri’s picture

not sure if you already found a way but there is an article on Lullabot: Quick-and-dirty CCK imports which might be helpful and give you some idea.

twen’s picture

Hey crystalcube,

That's exactly what I'm looking for ! With that article I can read (with some minor modification) my PostGreSQL database and insert new nodes.

Now, this cool for the very first time I've to create the nodes. FOr the next times, I need to also check if nodes doesn't exist already and update then if needed :) I should find the right functions here I guess : http://api.drupal.org/api/5/function

Thanks !

vivek.puri’s picture

Thats right. What you are looking for is node_load api function , which will load the relevant node if it exists.

twen’s picture

Right, I found out from googling. Thanks however for the notice :)

twen’s picture

Hello,

Just to tell you that I did code the migration script I needed, and it's working fine :) A colleague wrote the PostGreSQL export, and I inserted the drupal API fiunction to add the datas (I used drupal-execute() for this).

Thank to you all.