Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By twen on
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.
- 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 ?
- 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
if you write a migration
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.
PHP Migration script
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.
Help from a newbie; follow at your own risk
It's my understanding that the place to start is with
require_once './includes/bootstrap.inc'
. Then you calldrupal_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 . :)
not sure if you already
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.
Thanks !
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 !
Thats right. What you are
Thats right. What you are looking for is node_load api function , which will load the relevant node if it exists.
Right, I found out from
Right, I found out from googling. Thanks however for the notice :)
Update... :)
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.