Devart ODBC Driver for Stripe: Data Source Name Configuration and Stripe Access from PHP, Python, and Power BI

October 25th, 2022

In this article, we will discuss how to configure a DSN and connect to Stripe from Python, PHP, and Power BI using the ODBC driver for Stripe.

Devart ODBC Driver for Stripe is a  high-performance connectivity tool that allows accessing Stripe from both 32-bit and 64-bit Windows. The driver provides an efficient, enterprise-grade method of connecting to the data sources and quick, secure access to live Stripe data from any machine. ODBC driver for Stripe supports all of the standard ODBC API operations and data types.

Key Features

The Stripe Link

Our data connector enables ODBC-compatible software to securely communicate with Stripe over the Internet. If you are blocked from using Stripe, you may still connect to the service using a proxy server.

Extended SQL Syntax

The ODBC driver makes it possible to use Stripe objects as standard SQL tables inside your software. The extended SQL syntax allows for the use of all the benefits of SQL in SELECT queries that are compatible with SQL-92:

  • Complex JOINs
  • WHERE conditions
  • Subqueries
  • GROUP statements
  • Aggregation functions
  • ORDER statements

DML Operations Support

You can perform DML operations like INSERT, UPDATE, or DELETE on your data using the Devart ODBC Driver for Stripe, which is impossible with SQL databases.

ODBC Conformance Indicators

The driver fully supports the ODBC interface. So when using an ODBC Data Type, you may use one of the many ODBC API Functions available.

Furthermore, we assist with more complex Connection String parameters. Stripe may be integrated with any ODBC-enabled system, whether it is a desktop application or a web service.

Stripe Compatibility

The ODBC driver works with all of the file types supported by the Stripe API. The driver is also compatible with Stripe’s API.

Integration

With the Devart ODBC drivers, you may access any data sources from various IDEs, reporting, or data analysis tools, for example, Microsoft Excel in different operating systems.

See the Compatibility page for a full rundown of compatible programs and devices.

Variety of Platforms

The Devart ODBC Driver for Stripe works with 32-bit and 64-bit applications on x32 and x64 platforms, so there’s no need to configure the driver, software, or environment additionally.

Driver for Unicode-Compatible Devices

For multilingual Stripe databases, our fully Unicode driver guarantees error-free data retrieval and processing, no matter the charset used for the data (Latin, Cyrillic, Hebrew, Chinese, etc.).

The Highest Level of Efficiency

Our driver can do everything with Stripe substantially faster because of local data caching, connection pooling, query optimization, and other features.

Support

Visit our Support page for instantaneous help from qualified professionals, rapid problem resolution, and the latest hotfixes in nightly releases.

To see the full list of the Features, follow the Features page.

ODBC Driver Configuration for Stripe

Microsoft Windows DSN Setup

To begin with, we would like to point out that the Windows search box is where you will go to find ODBC Data Sources. Once you find it, choose the version corresponding to the program’s bitness (32-bit or 64-bit). Control Panel > Administrative Tools is also where you’ll discover ODBC Data Sources. Earlier versions of Windows referred to the icon as Data Sources (ODBC).

You may also build a 32-bit DSN by running С:WindowsSystem32odbcad32.exe, or a 64-bit DSN by using C:WindowsSysWOW64odbcad32.exe.

So, as soon as the driver has finished installing, follow the next steps.

  1. Open the ODBC Data Source Administrator and add a new DSN for Stripe by clicking Add button. Note that the ODBC driver for Stripe is preinstalled.
  2. You may choose the User DSN or System DSN menu. Although any DSN type may be used with most programs, some have stricter requirements.
  3. Add it by clicking the Add button. The prompt to set up a fresh data source will show up.
  4. Pick the Devart Stripe ODBC Driver and hit Finish. A window to configure the driver will appear.
  5. Fill up the required fields with your connection data.
  6. To make sure the connection is successful, choose Test Connection.
  7. The DSN will be saved when you click OK.

Creating an ODBC Trace Log on Windows

Activating or deactivating tracing in the 64-bit ODBC Administrator also activates or deactivates tracing in the 32-bit ODBC Administrator correspondingly.

Select Machine-Wide tracing for all user identities if the ODBC client program you need to trace uses the Local System account or a user login other than your own. For instance, this setting may be required for SSMS.

If you’re using Windows and ODBC Source Administrator, you may create a trace file by following the instructions below.

  1. In Windows 10, type ODBC Data Sources into the search box (in older versions of Windows, enter Control Panel > Administrative Tools) and choose the appropriate bitness from the drop-down menu.
  2. Find the Tracing menu and click it.
  3. If you need to, you may modify the default location of the log files. Verify that the program can write the path, and then press the Apply button.
  4. Select Trace Now to begin.
  5. It’s time to reboot the whole system’s software.
  6. To ensure the driver can connect, go to the DSN settings and click the Test Connection button.
  7. On the Tracing tab, choose Stop Tracing Now.
  8. Forward the collected log file to us (for example, devart.log).

Creating an ODBC Trace Log on macOS

Use the ODBC Administrator’s Tracing tab to activate the tracing feature on macOS.

  1. Open the ODBC Administrator.
  2. Find the Tracing menu and click it.
  3. You may modify the default location of the Log file if you need to.
  4. Choose Always from the When to trace dropdown.

Creating an ODBC Trace Log on Linux

In Linux, you may monitor ODBC calls by configuring the Trace and TraceFile keyword/value pairs in the [ODBC] section of the /etc/odbcinst.ini file, as shown below:

[ODBC]
Trace=Yes
TraceFile=/home/test/devart.log

After you have obtained a log file, you should turn off logging since it slows down read and write operations.

Using the ODBC Driver for Stripe in Third-Party Tools

ODBC Driver for Stripe is compliant with the following ODBC tools:

  • DBeaver
  • Oracle Database Link
  • Microsoft Access
  • Microsoft Excel
  • OpenOffice and LibreOffice
  • PHP
  • Power BI
  • Python
  • QlikView
  • SQL Server Management Studio
  • SSIS
  • Tableau

To get more information about using ODBC Driver for Stripe in Third-Party Tools, check out the documentation.

Importing Stripe Data into Power BI through an ODBC Connection

Power BI is a well-known business intelligence solution that includes services, applications, and connectors for aggregating and analyzing data from various sources. Using an ODBC driver, Power BI may be linked to multiple databases.

With the help of an ODBC driver for Stripe, you can access Stripe directly from Power BI Desktop and import the needed data. It is expected that an ODBC driver for Stripe has previously been installed and set up on your machine.

  1. Launch Power BI Desktop and choose Get Data to analyze your information.
  2. Select Other > Get Data > ODBC. To finalize your selection, click Connect.
  3. Click the down arrow next to Data Source Name (DSN) in the From ODBC dialog box, then choose the DSN you set up for Stripe.
  4. If you want to input a SQL statement to filter the results, you may expand the dialogue box and click the Advanced options arrow.
  5. Click OK. If your data source requires authentication, Power BI will ask for your credentials. Then, enter your Username and Password into the corresponding boxes and click the Connect button.
  6. Now you can view the data structures in your data source by clicking on a database item. Select the table you need to import into Power BI from Stripe, and click Load.

Connecting to Stripe from Python using the ODBC Driver for Stripe

Connection to various databases and cloud services and retrieving data from them from Python is easier with ODBC. To operate with Python, you need first to download it from the official website and run the installer. Besides, the pyodbc module must be established. In Python’s interactive mode, this may be done with the command pip install pyodbc.

Then all you need to use the driver as a translation layer between your application and the data source is to configure a DSN (Data Source Name). To do this, follow the steps below:

Step 1: Connect

import pyodbc 
cnxn = pyodbc.connect('DRIVER={Devart ODBC Driver for Stripe};Account ID=myaccountid, Secret Key=mykey')

Step 2: Insert a row

To verify your database connection, look at this elementary example of running an insert command. A new entry is added to the EMP table due to the script.

cursor = cnxn.cursor()
cursor.execute("INSERT INTO EMP (EMPNO, ENAME, JOB, MGR) VALUES (535, 'Scott', 'Manager', 545)")

Step 3: Execute the query

Selected query rows are returned by the cursor.execute() function. The print() method outputs all table records to the terminal, whereas the cursor.fetchone() function iterates across the result set produced by cursor.execute().

cursor = cnxn.cursor()	
cursor.execute("SELECT * FROM EMP") 
row = cursor.fetchone() 
while row:
    print (row) 
    row = cursor.fetchone()

Connecting to Stripe from PHP using ODBC Driver for Stripe

Regarding creating websites, PHP is among the most widely used languages. ODBC connectors allow PHP developers to be database-agnostic, meaning that your PHP-based product will run with any vendor’s DBMS. SQL queries may be prepared and run against databases like MySQL, SQLite, PostgreSQL, and more with the help of tools like odbc exec().

Data storage, either in the form of a local server or on the cloud, is a common need for PHP-based projects. Through the ODBC driver, you may connect to them. Our ODBC drivers allow you to connect to several data sources and get data from databases, including their tables and fields.

To establish a connection to the Stripe database and retrieve every record from a specific table, the PHP script is used. Below you can see such an example of a PHP script.

Step 1: Connect to an ODBC data source.

To link to an ODBC data source, use the odbc_connect() function. Please be aware that the function requires three inputs: the name of the data source, the user’s name, and their password. Leave these fields blank if your database does not need a password or login. Using the odbc_connect() function in PHP, the following code connects to a database.

?php
    $user = "myusername"; 
    $password = "mypassword";
    $ODBCConnection = odbc_connect("DRIVER={Devart ODBC Driver for Stripe};Account ID=myaccountid, Secret Key=mykey", $user, $password);

Step 2: Execute an SQL statement

A SELECT query is executed on the dept table in the autotest database through the odbc_exec() function if the connection is successful.

$SQLQuery = "SELECT * FROM autotest.dept";
    $RecordSet = odbc_exec($ODBCConnection, $SQLQuery);

Step 3: Print the result set

The data in the result set is provided by the odbc_fetch_row() function. The odbc_result_set() method outputs a set of results in an HTML table, while the odbc_fetch_row() function retrieves rows. The odbc_close() function terminates the connection when the result set’s rows have been printed.

while (odbc_fetch_row($RecordSet)) {
        $result = odbc_result_all($RecordSet, "border=1");
    }
    odbc_close($ODBCConnection);
?> 

To use other ODBC drivers with your PHP application, you can modify this script by specifying another setting for a certain driver.

Comments are closed.