本記事では CData サポート担当からこんなことを聞かれたらどこを確認すべきか?という観点で、よく頂くお問合せ内容をご紹介します。
記事はこちら →Python エコシステムには多くのモジュールがあり、システム構築を素早く効率的に行うのに役立ちます。CData Python Connector for BullhornCRM は、pandas、Matplotlib モジュール、SQLAlchemy ツールキットから使用することで Bullhorn CRM にデータ連携するPython アプリケーションを構築し、Bullhorn CRM をビジュアライズできます。本記事では、pandas、SQLAlchemy、およびMatplotlib のビルトイン機能でBullhorn CRM にリアルタイムアクセスし、クエリを実行し、結果をビジュアライズする方法を説明します。
CData Python Connector は、ビルトインされた効率的なデータプロセスにより、リアルタイムBullhorn CRM データにPython からアクセスし、高いパフォーマンスと接続性を発揮します。Bullhorn CRM に複雑なクエリを投げる際に、ドライバーはフィルタリング、集計などがサポートされている場合、SQL 処理を直接Bullhorn CRM 側に行わせ、サポートされていないSQL 処理については、組み込まれたSQL エンジンによりクライアント側で処理を行います(特にJOIN やSQL 関数など)。
Bullhorn CRM への連携は、RDB ソースへのアクセスと同感覚で行うことができます。必要な接続プロパティを使って接続文字列を作成します。本記事では、接続文字列をcreate_engine 関数のパラメータとして送ります。
Begin by providing your Bullhorn CRM account credentials in the following:
If you are uncertain about your data center code, codes like CLS2, CLS21, etc. are cluster IDs that are contained in a user's browser URL (address bar) once they are logged in.
Example: https://cls21.bullhornstaffing.com/BullhornSTAFFING/MainFrame.jsp?#no-ba... indicates that the logged in user is on CLS21.
Bullhorn CRM uses the OAuth 2.0 authentication standard. To authenticate using OAuth, create and configure a custom OAuth app. See the Help documentation for more information.
以下の手順に従い、必要なモジュールをインストールし、Python オブジェクト経由でBullhorn CRM にアクセスします。
pip で、pandas & Matplotlib モジュールおよび、SQLAlchemy ツールキットをインストールします:
pip install pandas pip install matplotlib pip install sqlalchemy
以下のようにモジュールをインポートします:
import pandas import matplotlib.pyplot as plt from sqlalchemy import create_engine
次は、接続文字列で接続を確立します。create_engine 関数を使って、Bullhorn CRM に連携するEngne を作成します。.
engine = create_engine("bullhorncrm:///?DataCenterCode=CLS33&OAuthClientId=myoauthclientid&OAuthClientSecret=myoauthclientsecret&InitiateOAuth=GETANDREFRESH&OAuthSettingsLocation=/PATH/TO/OAuthSettings.txt")
pandas のread_sql 関数を使って好きなSQL を発行して、DataFrame にデータを格納します。
df = pandas.read_sql("""SELECT Id, CandidateName FROM Candidate WHERE CandidateName = 'Jane Doe'""", engine)
DataFrame に格納されたクエリ結果に対して、plot 関数をつかって、Bullhorn CRM data をグラフで表現してみます。show メソッドはグラフを新しいウィンドウに表示します。
df.plot(kind="bar", x="Id", y="CandidateName") plt.show()
Bullhorn CRM Python Connector の30日の無償トライアル をぜひダウンロードして、Bullhorn CRM への接続をPython アプリやスクリプトから簡単に作成しましょう。
import pandas import matplotlib.pyplot as plt from sqlalchemy import create_engin engine = create_engine("bullhorncrm:///?DataCenterCode=CLS33&OAuthClientId=myoauthclientid&OAuthClientSecret=myoauthclientsecret&InitiateOAuth=GETANDREFRESH&OAuthSettingsLocation=/PATH/TO/OAuthSettings.txt") df = pandas.read_sql("""SELECT Id, CandidateName FROM Candidate WHERE CandidateName = 'Jane Doe'""", engine) df.plot(kind="bar", x="Id", y="CandidateName") plt.show()