We’re bringing you all new Laravel and Python connectors in SingleStoreDB. Here’s what’s new — and how you can try them out.
Laravel Connector Ready for Production!
We shipped the 1.0 release of our native Laravel connector back in June, but haven't stopped improving it since then! In total we have had 12 contributions from six contributors since 1.0.
For the uninitiated, Laravel is a PHP framework for building modern web applications. It's used by some amazing companies you may have heard about including Twitch, Disney, The New York Times and Fathom Analytics. Laravel is focused on developer productivity and generally getting out of your way to let you build applications quickly.
The official SingleStoreDB Laravel Connector extends Laravel's built-in ORM (Eloquent) to support SingleStoreDB specific features including shard keys and JSON. This allows you to do something like this, which wouldn't work out of the box in Laravel:
Schema::create('events', function (Blueprint $table) {
$table->string('name')->unique()->shardKey();
$table->json('properties');
$table->datetime('created_at')->sortKey()->seriesTimestamp();
});
The functions are all extensions our connector adds to Eloquent to support the similarly named features in SingleStoreDB.
You can install our Laravel connector via composer:
composer require singlestoredb/singlestoredb-laravel
You can also find the driver and it's documentation on Github.
See more: Laravel and SingleStoreDB Quickstart Guide
SingleStoreDB for Laravel Masterclass With Jack Ellis
Jack Ellis (co-founder and CTO of Fathom Analytics) released a masterclass on building Laravel applications using SingleStoreDB as the database. You can get the course here.
The course teaches you the fundamentals of how SingleStoreDB works, as well as Laravel specific techniques which will make you more successful. I believe that this course benefits everyone — not just Laravel developers — as many of the lessons Jack teaches are generalizable to all SingleStoreDB users.
If you still aren't sold on the course, I encourage you to read Jack's blog post on building the world's fastest website analytics using SingleStoreDB and Laravel.
I got tired of MySQL headaches and needed something faster and more scalable. So we ditched MySQL, Redis and DynamoDB, moved everything to SingleStore, and are now able to achieve hyper-scale and performance we’d never imagined.
Jack Ellis, Fathom Analytics
Python Connector — Now With "Super Velocity" Mode
Our resident Python expert, Kevin Smith, has been hard at work creating a fork of PyMySQL (a pure-python MySQL client) that goes a lot faster. He calls it PyMySQLsv. In his words, 'sv' is borrowed from the Lamborghini Aventador SuperVeloce. SuperVeloce is Italian for "super velocity".
So, just how fast does it go? Compared to PyMySQL, PyMySQLsv is roughly 10x faster in processing rows. Compared to the MySQLdb and mysql.connector drivers (both accelerated by native C extensions), PyMySQLsv runs 2x and 1.5x faster, respectively. And all of this is without rewriting the entire driver. We have documented these benchmark results in the readme, which you can find here.
Our official Python connector supports the full DB-API v2.0 specification allowing it to automatically work with any library based around DB-API v2.0. It also works with the SingleStoreDB Data API, as well as providing a full python client for the Singlestore Helios Management API . You can explore our documentation for more on these features.
You can use this new driver by installing the official SingleStoreDB-Python connector through pip:
pip install singlestoredb
You can also find the driver and it's documentation on Github.
SQLAlchemy & Ibis Support
The Python ecosystem is packed full of the worlds best developer friendly libraries. Two libraries that stand out in the data landscape are SQLAlchemy and Ibis.
SQLAlchemy Dialect
SQLAlchemy is the most used SQL toolkit and ORM for Python. Tons of frameworks and other libraries depend on SQLAlchemy to provide abstractions over SQL databases. Because of that, SingleStoreDB has built an official SQLAlchemy Dialect, allowing you to use SQLAlchemy with our official Python connector (yeah, the super fast one we talked about above). You can install this dialect through pip:
pip install sqlalchemy-singlestoredb
You can also find the driver and it's documentation on Github.
Ibis Backend
Ibis is a dataframe abstraction in Python which is lazily evaluated. This allows you to express complex operations through the dataframe API, then push the computation to execute within the SingleStoreDB distributed system. This can enable you to run certain operations that would be impossible using something like Pandas.
You can use the Ibis backend by installing it through pip:
pip install ibis-singlestoredb
You can also find the driver and it's documentation on Github.
Here is an example of using Ibis to query SingleStoreDB:
import ibis
# Connect using the default connector
conn = ibis.singlestoredb.connect('user:password@host:3306/db_name')
# Get an Ibis DataFrame object that points to the 'employees' table
employees = conn.table('employees')
# Apply DataFrame-like operations (lazily)
res = employees[employees.name.like('Smith')][employees.deptId > 1]
# Execute the operations entirely within SingleStore,
# only returning the results to Python
res.execute()
If you want to learn more about Ibis, please take a look at the following resources:
- Ibis for Pandas Users
- Ibis for SQL Users
- Exploratory Data Analysis of Titanic Data with SingleStoreDB
- Ibis Homepage
You can also try SingleStoreDB free today.