oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
308 stars 61 forks source link

OSError: [WinError 10038] An operation was attempted on something that is not a socket #268

Closed danilyef closed 6 months ago

danilyef commented 6 months ago

I am trying to connect to my Oracle Database, but throws me an error: OSError: [WinError 10038] An operation was attempted on something that is not a socket

  1. What versions are you using?
  1. Is it an error or a hang or a crash?
  1. What error(s) or behavior you are seeing?
oracledb.connect(user="username",
                password="password",
                dsn="hostname:port/servicename"
)

Error:

DatabaseError                             Traceback (most recent call last)
File src\\oracledb\\impl/thin/connection.pyx:328, in oracledb.thin_impl.ThinConnImpl.connect()

File src\\oracledb\\impl/thin/connection.pyx:215, in oracledb.thin_impl.ThinConnImpl._connect_with_params()

File src\\oracledb\\impl/thin/connection.pyx:186, in oracledb.thin_impl.ThinConnImpl._connect_with_description()

File src\\oracledb\\impl/thin/connection.pyx:127, in oracledb.thin_impl.ThinConnImpl._connect_with_address()

File src\\oracledb\\impl/thin/protocol.pyx:246, in oracledb.thin_impl.Protocol._connect_phase_two()

File src\\oracledb\\impl/thin/protocol.pyx:381, in oracledb.thin_impl.Protocol._process_message()

File src\\oracledb\\impl/thin/protocol.pyx:359, in oracledb.thin_impl.Protocol._process_message()

File src\\oracledb\\impl/thin/protocol.pyx:430, in oracledb.thin_impl.Protocol._receive_packet()

File src\\oracledb\\impl/thin/packet.pyx:561, in oracledb.thin_impl.ReadBuffer.receive_packet()

File src\\oracledb\\impl/thin/packet.pyx:360, in oracledb.thin_impl.ReadBuffer._receive_packet_helper()

File src\\oracledb\\impl/thin/packet.pyx:206, in oracledb.thin_impl.ReadBuffer._get_data_from_socket()

File [~\AppData\Roaming\Python\Python311\site-packages\oracledb\errors.py:127](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/yefimoda/OneDrive%20-%20Hutchison%20Drei%20Austria%20GmbH/Desktop/drei-email-classifier/~/AppData/Roaming/Python/Python311/site-packages/oracledb/errors.py:127), in _raise_err(error_num, context_error_message, cause, **args)
...
File src\\oracledb\\impl/thin/connection.pyx:235, in oracledb.thin_impl.ThinConnImpl._force_close()

File src\\oracledb\\impl/thin/protocol.pyx:353, in oracledb.thin_impl.Protocol._force_close()

OSError: [WinError 10038] An operation was attempted on something that is not a socket
  1. Does your application call init_oracle_client()?
  1. Include a runnable Python script that shows the problem.
connection =oracledb.connect(user="username",
                password="password",
                dsn="hostname:port/servicename"
cjbj commented 6 months ago

@danilyef I hope that wasn't your real password!

What's the full DB version number? Is the DB also on the same machine?

Does Thick mode connect OK?

Is the CREATE TABLE clause relevant?

anthony-tuininga commented 6 months ago

Is there an error earlier that was reported? If so, this issue has already been resolved. If you can build from source you can verify that fact. If not, you can wait for the upcoming version 2.0 release which is planned to be released soon.

danilyef commented 6 months ago

@cjbj

---------------------------------------------------------------------------
DatabaseError                             Traceback (most recent call last)
Cell In[14], line 1
----> 1 oracledb.init_oracle_client() 
      2 oracledb.connect(user="username",
      3                 password="password",
      4                 dsn="hostname:port/servicename")

File src\\oracledb\\impl/thick/utils.pyx:476, in oracledb.thick_impl.init_oracle_client()

File src\\oracledb\\impl/thick/utils.pyx:500, in oracledb.thick_impl.init_oracle_client()

File src\\oracledb\\impl/thick/utils.pyx:421, in oracledb.thick_impl._raise_from_info()

DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "C:\Oracle\product\12.2.0\client_1\bin\oci.dll is not the correct architecture"
cjbj commented 6 months ago

@danilyef Anthony has a more useful answer, but for what it's worth, 19.0.0.0.0 is not the full DB number. There will be another 19.x number with a non-0 x somewhere.

You need to install an Oracle client to enable Thick mode, see https://python-oracledb.readthedocs.io/en/latest/user_guide/initialization.html#enabling-python-oracledb-thick-mode