Skip to content

Commit

Permalink
[ADD] MySQL and PostgreSQL database documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mccwdev committed Jan 14, 2020
1 parent 90b365a commit c77315e
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 7 deletions.
10 changes: 9 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Some Examples
Wallet
------

The bitcoin library contains a wallet implementation using sqlalchemy and sqllite3 to import, create and manage
The bitcoin library contains a wallet implementation using SQLAlchemy and SQLite3 to import, create and manage
keys in a Hierarchical Deterministic way.

Example: Create wallet and generate new address (key) to receive bitcoins
Expand Down Expand Up @@ -227,6 +227,14 @@ Example: Get estimated transaction fee in sathosis per Kb for confirmation withi
138964
Other Databases
---------------

Bitcoinlib uses the SQLite database by default but other databases are supported as well.
See http://bitcoinlib.readthedocs.io/en/latest/_static/manuals.databases.html for instructions on how to use
MySQL or PostgreSQL.


More examples
-------------
For more examples see https://github.com/1200wd/bitcoinlib/tree/master/examples
Expand Down
59 changes: 59 additions & 0 deletions docs/_static/manuals.databases.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Using MySQL or PostgreSQL databases
===================================

Bitcoinlib uses the SQLite database by default, because it easy to use and requires no installation.

But you can also use other databases. At this moment Bitcoinlib is tested with MySQL and PostgreSQL.


Using MySQL database
--------------------

We assume you have a MySQL server at localhost. Unlike with the SQLite database MySQL databases are not created
automatically, so create one from the mysql command prompt:

.. code-block:: mysql
mysql> create database bitcoinlib;
Now create a user for your application and grant this user access. And off course replace the password 'secret' with
a better password.

.. code-block:: mysql
mysql> create user bitcoinlib@localhost identified by 'secret';
mysql> grant all on bitcoinlib.* to bitcoinlib@localhost with grant option;
In your application you can create a database link. The database tables are created when you first run the application

.. code-block:: python
db_uri = 'mysql://bitcoinlib:secret@localhost:3306/bitcoinlib'
w = wallet_create_or_open('wallet_mysql', db_uri=db_uri)
w.info()
Using PostgreSQL database
-------------------------

First create a user and the database from a shell. We assume you have a PostgreSQL server running at your Linux machine.

.. code-block:: bash
$ su - postgres
postgres@localhost:~$ createuser --interactive --pwprompt
Enter name of role to add: bitcoinlib
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
$ createdb bitcoinlib
And assume you unwisely have chosen the password 'secret' you can use the database as follows:

.. code-block:: python
db_uri = 'postgresql://bitcoinlib:secret@localhost:5432/'
w = wallet_create_or_open('wallet_mysql', db_uri=db_uri)
w.info()
25 changes: 19 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,23 @@
Welcome to Bitcoinlib's documentation!
======================================

Bitcoin and other Cryptocurrencies Library for Python. Includes a fully functional
wallet, Mnemonic key generation and management and connection
with various service providers to receive and send blockchain and transaction information.
Bitcoin, Litecoin and Dash Crypto Currency Library for Python.

Includes a fully functional wallet, with multi signature, multi currency and multiple accounts.
You this library at a high level and create and manage wallets for the command line or at a low level
and create your own custom made transactions, keys or wallets.

The BitcoinLib connects to various service providers automatically to update wallets, transactions and
blockchain information. It does currently not parse the blockchain itself.


Wallet
------

The bitcoinlibrary contains a wallet implementation using sqlalchemy and sqllite3 to import, create and manage
This Bitcoin Library contains a wallet implementation using SQLAlchemy and SQLite3 to import, create and manage
keys in a Hierarchical Deterministic Way.

Example: Create wallet and generate new key to receive bitcoins
Example: Create wallet and generate new address to receive bitcoins

.. code-block:: python
Expand All @@ -33,7 +38,7 @@ Example: Create wallet and generate new key to receive bitcoins
When your wallet received a payment and has unspent transaction outputs, you can send bitcoins easily.
If succesfull a transaction ID is returned
If successful a transaction ID is returned
.. code-block:: python
Expand Down Expand Up @@ -172,6 +177,14 @@ Example: Get estimated transactionfee in sathosis per Kb for confirmation within
138964
Other Databases
---------------
Bitcoinlib uses the SQLite database by default but other databases are supported as well.
See http://bitcoinlib.readthedocs.io/en/latest/_static/manuals.databases.html for instructions on how to use
MySQL or PostgreSQL.
More examples
-------------
For more examples see https://github.com/1200wd/bitcoinlib/tree/master/examples
Expand Down

0 comments on commit c77315e

Please sign in to comment.