I am getting quite confused on how to approach connecting to SQL server from a Python Lambda function. At this point, I am just trying to connect to my SQL Server (Azure) instance from the recommended AMI image .
The first and most popular approach seems to be using pymssql. Within that, it seems like you can go with the precompiled FreeTDS version (export PYMSSQL_BUILD_WITH_BUNDLED_FREETDS=1) or you can install FreeTDS on your system.
I have tried both and always ended up with the following error:
>>> pymssql.connect('myserver.database.windows.net', 'myuser#myserver.database.windows.net', 'mypass', 'mydb')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pymssql.pyx", line 641, in pymssql.connect (pymssql.c:10824)
pymssql.OperationalError: (20002, 'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (myserver.database.windows.net:1433)\n')
Note, that if I install FreeTDS on the system and attempt to connect with tsql, I have no problems at all.
I can provide more info on exactly how my installs are setup if someone can help me with this approach. Alternatively, I am happy to go the pyodbc route but would need some help in that direction, too.
Update:
I tried going the pyodbc route and managed to get the drivers installed following this guide. Will update on future progress
Related
I have tried to install the ODBC driver 18 for SQL Server in my symfony project. I am getting the following error messages. I wanted to ask if anyone could knows the solution for these.
An exception occurred in the driver: SQLSTATE[08001]: [Microsoft][ODBC
Driver 18 for SQL Server]SSL Provider: [error:16000069:STORE
routines::unregistered scheme:scheme=file][error:80000002:system
library::No such file or direc tory:calling
stat(/usr/local/etc/openssl#3/certs)][error:16000069:STORE
routines::unregistered scheme:scheme=file]
Environment details:
symfony version: 5.4.16
php8.1
Homebrew 3.6.16
apache 2.4.54
#AlwaysLearning's answer did help me.From the article linked, I checked the openssl#3 folder and I did see there was a cert.pem file. I then created a certs directory and copied the cert.pem file into that directory. That got of rid of my error message.
I did encounter an additional issue where I needed to add TrustServerCertificate parameter to the end of my connection string that is used to connect to the SQL server.
;TrustServerCertificate=1
I have been trying to upgrade SQL server 2017 to run Python 3.7. We have installed CU28 and the product version is 14.0.3430.2 which includes the C:\Program Files\Microsoft SQL Server\MSSQL14.INSTANCENAME\PYTHON_SERVICES.3.7.
I have made sure all permissions are granted to the INSTANCENAME directory and pythonlauncher.config working directory is pointing to C:\Program Files\Microsoft SQL Server\MSSQL14.INSTANCENAME\MSSQL\ExtensibilityData and launchpad service account has permissions to this directory.
I have done all this as an upgrade twice and got various errors, and a clean install. The error I am getting is
Msg 39004, Level 16, State 20, Line 0
A 'Python' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 2, Line 0
An external script error occurred:
Invalid BXL stream
error while running BxlServer: caught exception: Error communicating between BxlServer and client: 0x000000e8
HRESULT 0x000000e8 looks like INVALID_CANCEL_OF_FILE_OPEN
HRESULT 0x80004004 looks like E_ABORT
So no real clues what is wrong here. pythonlauncher.log does show the error;
[Error] Process::TryTerminate failed with error code: 5
Session 0E93E9D1-07A7-448A-8B1A-FCA5263A5F53 TryTerminate(1067) failed with 5
Error code 5 is ERROR_ACCESS_DENIED
Also got this warning
[Warning] StaleDirectoryCleaner() failed to delete C:\Program Files\Microsoft SQL Server\MSSQL14.INSTANCENAME\MSSQL\ExtensibilityData\FAMSQL17UAT01\8B97815A-E9EA-4FA0-98F3-0440D4180522 after 5 retries
So all up this looks there are still permission issues. Extremely frustrating as there is next to no help on this. Any help would be greatly appreciated.
UPDATE:
After another clean install - first checked Python 3.5.2 worked and it did. Upgraded to 3.7, and again got the same issue. A bit more digging around I find this...
The SQL Server Network Interface library could not register the Service Principal Name (SPN) [ MSSQLSvc/SERVERNAME.domain_name.com:INSTANCENAME ]
Login failed for user 'DOMAIN\SERVERNAME$'. Reason: Could not find a login matching the name provided.
We have a service account that is not part of the domain which is NT Service\MSSQL$INSTANCENAME. Why on this implementation expecting a windows authenticated user the same name as the server??? How can I go about remedy this?
I think what has happened is that MS have left debug code in their production release.
FURTHER UPDATE:
In the event log we are seeing
Faulting application:Python.exe: 3.7.1150.1013 Faulting module name:
pylink.pyd Faulting module path:c:\Program Files\Microsoft SQL
Server\MSSQL14.INSTANCENAME\PYTHON_SERVICES.3.7\lib\site-packages\revoscalepy\rxLibs\pylink.pyd
Microsoft have confirmed that this is a bug. Their work around is below.
It's CU27 and CU28 that 3.7 is broken in - so you could use CU26 and still use Python 3.7. That version started at CU22... so CU22-26 work fine.
Or - it's only the pylink.pyd that is broken - you can simply grab the pylink.pyd from a CU22-26 installation for Python 3.7, and swap it into your CU27/CU28 files. This workaround will work now, and will also not cause any issues going forward once the fix does come. That is, on your next update, it shouldn't interfere and it should all go smoothly.
I want to use the airflow 2.01 docker-compose file from apaches github.
here is the link docker-compose.yaml and here is the link to the dockerfiledockerfile
I want to use a Dag which should grab data out of my SQL Server database. Actually I get the following error:
no module named pymssql
After I manually installed it, I get an error like no module named pyodbc.
When I want to install this manually I get an gcc error, that it is not possible to install.
Does anyone have any clue about this?
Is there any docker-compose file which is able to handle SQL Server connection for Airflow 2?
Thanks in advance
First things first, I read and tried stuff I found online even from this website, but can't get it to work.
I have an SQL SERVER 2014 running on Windows Server 2012, there I have a WAMP 64 bits running Apache on PHP 7.1.6 and need to connect to the Database, apparently the extension is not loaded because I'm getting the undefined function error.
$conn = sqlsrv_connect( $APIDBSERVER, $connection);
What I've done so far:
Installed Microsoft® ODBC Driver 11 for SQL Server
Downloaded PHP SQL Driver 4.0 and moved php_sqlsrv_7_nts_x64.dll to /ext
Added them to php.ini:
extension=php_pdo_sqlsrv_7_nts_x64.dll
extension=php_sqlsrv_7_nts_x64.dll
Apparently the PDO also needs php_pdo.dll which WAMP doesn't have and I haven't found where to download it from, so I'm using the standard non-PDO approach
Recently even tried enabling odbc extensions which were disabled:
extension=php_odbc.dll
extension=php_pdo_odbc.dll
I access the php.ini through the WAMP menu so I know I'm editing the right one, restarted the server several times trying different things but I've run out of ideas.
Can you please help me?
EDIT:
PHP error log indicates the modules couldn't be found, but if I check that path they're right there, copy&pasted filenames into php.ini.
PHP Warning: PHP Startup: Unable to load dynamic library
'c:/wamp64/bin/php/php7.1.6/ext/php_pdo_sqlsrv_7_nts_x64.dll' - The
specified module could not be found. in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library
'c:/wamp64/bin/php/php7.1.6/ext/php_sqlsrv_7_nts_x64.dll' - The
specified module could not be found. in Unknown on line 0
EDIT 2:
Tried downgrading to 7.0.20 and get the same error, so the php.ini is fine, it just won't load them for a reason, will try to download ODBC 13.1 maybe?
Each PHP version might require a different version of the Microsoft PHP Drivers for SQL Server.
The link below shows compatibility between PHP and MS SQLSRV versions:
https://learn.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-ver15.
Because of the way WAMPServer is configures, NTS extensions do not run.
So change your process just a little and use the Thread safe dll's instead.
I was trying to install vertica using /opt/vertica/sbin/install_vertica script and following command /opt/vertica/sbin/install_vertica -s vertica001,vertica002,vertica003 -r /root/packages/vertica-6.0.1-7.x86_64.RHEL5.rpm
I was getting following error
Vertica Analytic Database 6.0.1-7 Installation Tool
Starting installation tasks...
Getting system information for cluster (this may take a while)....
'failed to login to 172.16.10.212: EOF ERROR: Could not login with SSH. Here is what SSH said: (publickey,gssapi-keyex,gssapi-with-mic).\r\r\n'
Updating Nodes that are UP
'failed to login to 172.16.10.18: EOF ERROR: Could not login with SSH. Here is what SSH said: (publickey,gssapi-keyex,gssapi-with-mic).\r\r\n'
Updating Nodes that are UP
Removing 172.16.10.212,172.16.10.18 from hosts list
backing up admintools.conf on 172.16.10.52
Info: the package 'pstack' is useful during troubleshooting. Vertica recommends this package is installed.
Checking/fixing OS parameters.....
Error: No JSON object could be decoded
Traceback (most recent call last):
File "/opt/vertica/bin/verticaInstall.py", line 1187, in <module>
if not SSH.check_min_free_kbytes(installerSSH, fix=True):
File "/opt/vertica/oss/python/lib/python2.7/site-packages/vertica/network/SSH.py", line 2388, in check_min_free_kbytes
data =json.loads( ''.join(res[host][1]))
File "/opt/vertica/oss/python/lib/python2.7/json/__init__.py", line 310, in loads
return _default_decoder.decode(s)
File "/opt/vertica/oss/python/lib/python2.7/json/decoder.py", line 346, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/opt/vertica/oss/python/lib/python2.7/json/decoder.py", line 364, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
I have setup passwordless ssh for dbadmin also it has sudo access.
Do I need to have passwordless ssh for root user here ? what I am missing here ?
Do I need to have passwordless ssh for root user here ? what I am missing here ?
Yes. The installer runs on the nodes specified in the host parameter. If SSH is not set up between the nodes, how else is the installer supposed to complete the process? See Configuring the Network and how to Enable Secure Shell (SSH) Logins in the doc.
Q: Why are you installing Vertica 6.0? The latest release is 7.2