Closed (fixed)
Project:
Feeds SQL
Version:
7.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
18 Jan 2013 at 14:39 UTC
Updated:
29 Jan 2019 at 17:45 UTC
Jump to comment: Most recent
Comments
Comment #1
FreeFox commentedI forgot the test php file, here it is:
Comment #1.0
FreeFox commentedAdded sponsor
Comment #3
summit commentedHi,
Will this also work to import MSSQL to Drupal using MongoDB for fields? See www.drupal.org/project/mongodb
I want to build a website with hunderdthousands of records. The source info is in MSSQL and I want to use drupal with MongoDB for performance issues.
Could feeds using sql parcer then set the fields in mongodb?
Thanks a lot in advance for your reply
greetings, Martijn
Comment #4
FreeFox commentedHi Summit,
The description I wrote is an explanation in general how I managed my import. If your Drupal is using mongodb, I don't see a reason why it wouldn't work because it is a connection to MSSQL on one side and Drupal at the other side. I presume the Feeds module works with Drupal whatever database is used so I believe it will work.
Given the instructions above it should be a small effort to try it out.
Success
Comment #5
actjksn commentedOn Step 4, I'm still getting an error 'could not find driver' when I'm setting the query in the SQL parser.
Is there anything else I need to do to tell Drupal about the dblib driver that I've dropped off in includes/database? Is it possible because I'm on openSuSE and the PHP modules don't work the same as in Cent?
Comment #5.0
actjksn commentedCorrected sponsor link
Comment #6
FreeFox commentedHi actjksn,
It could be possible that your installation doesn't use dynamic modules. To be sure:
1. Check if you have the mssql.so file
2. Check in php.ini or other php related files to see if there is a line: extension=mssql.so
3. After restarting httpd, check phpinfo() to see if there are mssql entries there. Mine look like this:
If you have these too, the first part should be working and you could test the php code in the 1st comment.
If this works too, php can connect with mssql and do queries.
Then you can check the permissions on the files and directories in /includes/database (compare with other files in de /includes folder)
If the files are there and the permissions are OK, double check the settings.php file.
Maybe a reboot of the server can help too.
Keep me posted so I can keep this post up-to-date.
Good luck.
Comment #7
papagrandeOn some servers, the MS SQL driver code may default to a different port than the standard 1433 or you need to put in your own specific port. In that case you need to put the port number into settings.php. However, the driver may not understand the port parameter so try putting the database connection setting as:
or
Comment #8
fishfree commentedIn the Settings for SQL parser page, when I click on the save button, it shows:
could not find driver
I did everything as described above. My mssql info in the phpinfo is as below:
mssql
MSSQL Support enabled
Active Persistent Links 0
Active Links 0
Library version FreeTDS
Directive Local Value Master Value
mssql.allow_persistent On On
mssql.batchsize 0 0
mssql.charset no value no value
mssql.compatability_mode Off Off
mssql.connect_timeout 5 5
mssql.datetimeconvert On On
mssql.max_links Unlimited Unlimited
mssql.max_persistent Unlimited Unlimited
mssql.max_procs Unlimited Unlimited
mssql.min_error_severity 10 10
mssql.min_message_severity 10 10
mssql.secure_connection Off Off
mssql.textlimit Server default Server default
mssql.textsize Server default Server default
mssql.timeout 60 60
Comment #8.0
fishfree commentedMake a few grammar changes
Comment #9
pavankumar7 commentedHello Freefox, I am new to the drupal world. I tried to follow your steps in getting drupal working against MS SQL, but I am stuck at step 4, was hoping you could shed some light on it. The place where you say
1) I presume here that you already have installed the Feeds module
2) Get the "Feeds SQL" module, install and enable it
3) Go into the Feeds UI and select the SQL fetcher
How do we install and enable it? I downloaded the module and unzipped it, but dont see any .sh files to install, also in step 3 you say go to feeds UI, what would the URL be? (localhost/feeds)?? Thank you for your help.
Comment #10
LGLC commentedAfter a day or two of trying everything under the sun, I finally got this working on both OSX and Ubuntu. The key things that were missing from the instructions above were the need to install PDO_DBLIB and the need to configure FreeTDS correctly.
1) GETTING THE CORRECT PHP EXTENSIONS
Firstly, you need to install the right drivers and enable the PHP extensions. The instructions differ depending on which OS you're running, so I’ll give steps for both.
Ubuntu
sudo apt-get install php5-odbc php5-sybase tdsodbcphp -msudo apache2ctl stopsudo apache2ctl startOSX (10.9 - Mavericks)
A lot of this was taken from http://goo.gl/1t8v0Q. If you use MAMP then I’ve highlighted where changes are necessary by including some MAMP insctructions below any normal OSX AMP stack instructions.
Then, use terminal to navigate to the extracted source directory and run the following commands:
To build and install the MSSQL extension, in Terminal change to the new MSSQL extension directory (php-5.4.17/ext/mssql) and run the below commands to build the mssql extension:
Non-MAMP version
MAMP version
To build and install the PDO_DBLIB extension, in Terminal change to the new PDO_DBLIB extension directory (php-5.4.17/ext/pdo_dblib) and run the below commands to build the pdo_dblib extension:
Non-MAMP version
MAMP version
Non-MAMP version
The file we need to edit is /etc/php.ini.
; extension_dir = "./"extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20100525/"sudo apachectl restart).MAMP version
The file we need to edit will be something like /Applications/MAMP/bin/php/php5.4.4/conf/php.ini (depending which version of PHP you use in MAMP).
2) CONFIGURING EVERYTHING
/includes/databaseas per the installation instructions.sudo nano /usr/local/freetds/conf/freetds/freetds.confEDIT: As explained in comment 13, I have had a situation where there instance_name wasn't needed. If you're having problems, try removing the '\\instance_name'.
Hope this helps someone else out at some point, as getting it all set up is far from trivial.
Comment #11
brianbrarian commentedThanks, this saved me a lot of time!
One thing to add, for anyone else setting up Feeds SQL to import data from an external MSSQL database: The column names in your SELECT query used in the Feeds SQL parser/mapping and in the importer node or form cannot include any uppercase characters. See https://drupal.org/node/1763872
Comment #12
kim-odisee commentedThanks for the information on this subject.
On my local dev machine - Mac OS X Mavericks - I still run into an issue retrieving MS SQL data. I followed the instructions from comment #10, this gave following error message retrieving data from Drupal.
In basic php-code I'm able to fetch all of my content using default mssql_connect() function and also via the PDO functions.
My PHP version:
PHP 5.4.24 (cli) (built: Jan 19 2014 21:32:15)
Any help?
Comment #13
LGLC commentedAfter one of our systems was moved to a different MSSQL server, I also started getting the SQLSTATE[] (null) (severity 0) message. After lots of trial and error, I eventually solved it by removing the instance name within settings.php.
So, for example:
Became:
(Where testServer was set up in the FreeTDS config as explained in my previous comment.)
On the new server, the server name was all that was used within SQL Management (i.e. it was just SERVERNAME, not SERVERNAME\SQLEXPRESS). Maybe this is why the host needed to be updated inside settings.php. (I still left the instance name as SERVERNAME inside of the FreeTDS config.)
Hopefully that will help with your issue.
As a note to others, I've found out that the SQL user you connect with must have their 'Default database' set up to the one you want to connect to. If this is not the case, even if they have access permissions to the database table you'd like to connect into, you'll get an SQL connection error. (Presumably you'd therefore need one user for each database you'd like to connect with.) That got rid of a headache I'd had for some time!
If you do have connection errors, it's also worth checking that the database can accept incoming connections and that the inbound Windows Firewall rules allow your IP to connect in to the MSSQL port.
Comment #14
LGLC commentedComment #15
lule75 commentedinterestingly I have done all the steps even before I found this post, and I assure you they work. However in my case, as obvious as it may sound when I import from mssql (external server data) to mssql which is holding my drupal system. it imports only one colomn on all rows. I have tried this now for 3 days no success. if some one has any idea why this is so. please help through, this is what i got in my error logs.
SQLSTATE[23000]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot insert duplicate key row in object 'dbo.node' with unique index 'vid_unique'.
Original item
array(
'ID1' => '1',
'Name' => 'lule ronald',
'Gender' => 'm',
'School' => 'lubiri',
'Location' => 'kamapa',
'dish' => 'posho',
)
then afterword gave this error
Missing bundle property on entity of type node.
Original item
array(
'ID1' => '2',
'Name' => 'kato husan',
'Gender' => 'm',
'School' => 'old kampala',
'Location' => 'lubaga',
'dish' => 'rice',
)
when it varnished, it went back to importing only a single column.
how can I return all my columns.
Comment #16
esteban.arias commentedThank you so much!!
I'm on a Debian 7.8 installation and needed to connect to an external database and dblib did the trick!
Comment #17
brettsh commentedThis was a lifesaver. Thank you.
Comment #18
vrwired commentedComment #10 was a golden contribution to this issue. Thank you for documenting those steps all in one place.
I also ran into issue of comment #13 (also noted/edited in comment #10). After removing instance name, I still had error but this time my freetds.log noted "Login failed for user ... checked my credentials in settings.php and corrected the password to success.
In nutshell found it helpful to enable log file in freetds.conf
Comment #19
bulldozer2003I have been successfully using the instructions from #10 with Drupal7 on PHP 5.4 for some time now. I am now looking into upgrading the PHP 7 but I have been having trouble because dblib does not appear to work in PHP 7.
Has anyone migrated Drupal 7 to PHP 7 and successfully connected to mssql?
Comment #20
brianbrarian commented@bulldozer2003 It's working for me. (Debian, Drupal 7.63, Feeds 7.x-2.0-beta4+14-dev, Feeds SQL 7.x-1.0)
AFAIK we didn't change anything in the setup for accessing the external mssql database (from #10 instructions) when we upgraded to PHP7.
Comment #21
bulldozer2003Thanks @brianbrarian What I did end up noticing is that the PHP 7 I was using in CentOS 7 wasn't built with freetds. If you run
php -i | grep -i tdsdoes it show your PHP was built with TDS? This is my result from PHP 5.4:PDO Driver for FreeTDS/Sybase DB-lib => enabledI did find a solution for my situation and it might be advantageous to others since the dblib project isn't being updated. I was able to use the sqlsrv project after installing Microsoft ODBC driver using instructions on stack overflow.
Step by step, what I did was:
Comment #22
brianbrarian commented@bulldozer2003 Yes, freetds is enabled, as it was when the installations were on PHP 5.6.