Using Python PYODBC library

You can use the pyodbc Python library to connect to the SQL Database with the CRM database. This can be used to select or update records. We use this in Extender scripts to select records from CRM and create transactions in Sage 300 (OE Orders or other) based on the selected records.

Note:

You need to tell the script to import the Python package as the PYODBC package is not installed with Extender.

For details, refer to: Importing Python packages

Copy

Using PYODBC library Example

#@ pip(pyodbc) 
# this will run pip to install the pyodbc package
import pyodbc
  cn = "Driver={SQL Server Native Client 11.0};Server=servername;Database=CRM;UID=user;PWD=passw"
  cnxn = pyodbc.connect(cn)

  cursor = cnxn.cursor()
  strQuery = "SELECT * FROM Company WHERE comp_deleted IS NULL "
 
  cursor.execute(strQuery)