Python Connector for NetSuite

Using the module - Python Connector for NetSuite

Using the module

To retrieve data from NetSuite:

  1. Import the module.
    import devart.netsuite as netsuite
  2. Connect to a database using the connect() module method and obtain a connection object:
    • If you're using basic authentication:
      my_connection = netsuite.connect(
          Ver=1,
      Authentication="Basic",
      UserID="your_username",
      Password="your_password",
      AccountId="your_account_id",
      RoleId="your_role_id",
      ApplicationId="your_application_id" )
    • If you're using token-based authentication:
      my_connection = netsuite.connect(
          Version="Ver2",
          Authentication="TokenBased",
          AccountId="your_account_id",
          AccountTimeZone="your_account_timezone",
          ConsumerKey="your_consumer_key",
          ConsumerSecret="your_consumer_secret",
          TokenId="your_token_id",
          TokenSecret="your_token_secret"
      )
    • If you're using OAuth 2.0 authentication:
      response = netsuite.signin(
          AccountId="your_account_id",
          ClientId="your_client_id",
          ClientSecret="your_client_secret")
      my_connection = netsuite.connect(
          Authentication="OAuth",
          AccountID="your_account_id",
          AccountTimeZone="your_account_timezone",
          ClientID="your_client_id",
          ClientSecret="your_client_secret",
          RefreshToken=response["Refresh Token"]
      )
  3. Create a cursor object using the cursor() connection method.
    my_cursor = my_connection.cursor()
  4. Execute the SQL statement using the execute() cursor method.
    my_cursor.execute("SELECT * FROM employees")
  5. Retrieve the result set using one of the fetch*() cursor methods.
    for row in my_cursor.fetchall(): 
        print(row)
© 2022-2025 Devart. All Rights Reserved. Request Support Python Connectors Forum Provide Feedback