Archive for January 21st, 2009
Seeking MySequel
Quite literally – I’d love to run into Chris II. Willing to bet he’s a bit more stable than the first version, namely, uh… me.
Problem: Importing a list of Users from an existing Databse to Drupal
Possibilities:
1. Node Import Module – I thought this was promising until the installation crashed my system.
2. CSV file import – but the problem was all the not-null fields being null – with 400 records to import, I wasn’t about to auto-fill all of them wtih a bunch of pregenerated text strings – who knows what would happen. And I found using PHPMyAdmin rather strict and unhelpful (which I realize was probably helpful).
3. Good ol’ SQL
Here’s what I did:
a. Export the existing databases.
b. Import them into a new temp database in my MySQL installation, called purgatory.
c. Create a new table in that database with columns corresponding to those which I want to update through SQL in the Drupal database. I discovered that the only feilds you really need are (name,pass,status). Status has to be 1 for the corresopnding login to work. Pass, however, needs MD5 encryption.
d. Insert the values from the old tables into the temp using: <code>INSERT INTO temp (name) SELECT username FROM oldtable.<code>
e. Update all records with pass and status using:<code>UPDATE temp SET pass=MD5(‘temporarypassstring’),status=1</code>
f. Check the temp to make sure it’s good.
g. Port temp into drupal users – go to drupal database and use this:<code>INSERT INTO users (name,pass,status) SELECT name,pass,status FROM pergatory.temp
h. BAM – 400 new users in my drupal installation, all with logins that work and temp passwords.
And Now…
To find a way to set that temporary password to something that the user has already given me, like an email address, or their first name.
I guess the PRO method would be to have a PHP script generate a temp password, update the SQL database and send an email to the user so we were out of the loop….
1 comment January 21, 2009