We are excited to release 0.1.2 of Doltpy. There are two main changes in this release:
- we made a slight tweak to the API to make it easier to work with
- we added support for bi-directional sync with Postgres instances
We have now successfully provided a simple API for interfacing between Dolt, and Postgres or MySQL. That means you can use Dolt to version and maintain valuable data, and then sync into your production system. Alternatively, you can use Dolt to version data that is stored in Postgres and MySQL.
Here is a simple example of syncing to a Postgres host:
python
import psycopg2
from doltpy.core import Dolt
from doltpy.etl.sql_sync import sync_from_dolt, get_dolt_source_reader, get_dolt_table_reader_diffs, get_postgres_target_writer
repo = Dolt('path/to/repo')
conn_str = "host='{host}' port='{port}' dbname='{dbname}' user='{user}' password='{password}'".format(
host=host,
port=port,
dbname=db,
user=user,
password=password
)
conn = psycopg2.connect(conn_str)
target_writer = get_postgres_target_writer(conn, True)
source_reader = get_dolt_source_reader(repo, get_dolt_table_reader_diffs())
sync_from_dolt(source_reader, target_writer, {'table': 'table'})
And syncing to Dolt from a Postgres host:
python
import psycopg2
from doltpy.core import Dolt
from doltpy.etl.sql_sync import sync_from_dolt, get_postgres_source_reader, get_postgres_table_reader, get_dolt_target_writer
repo = Dolt('path/to/repo')
conn_str = "host='{host}' port='{port}' dbname='{dbname}' user='{user}' password='{password}'".format(
host=host,
port=port,
dbname=db,
user=user,
password=password
)
conn = psycopg2.connect(conn_str)
target_writer = get_dolt_target_writer(repo, commit=True)
source_reader = get_postgres_source_reader(conn, get_postgres_table_reader())
sync_to_dolt(source_reader, target_writer, {'table': 'table'})
We have heard loud and clear from users and potential customers that Dolt needs to interoperate with existing relational database solutions, and this is our first attempt to solve this problem. As always we appreciate questions and bug reports in the issues on the Doltpy project.