James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 1 | :title: SQL Driver |
| 2 | |
| 3 | SQL |
| 4 | === |
| 5 | |
| 6 | The SQL driver supports reporters only. Only one connection per |
James E. Blair | 83786d4 | 2017-08-04 08:43:59 -0700 | [diff] [blame] | 7 | database is permitted. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 8 | |
James E. Blair | 83786d4 | 2017-08-04 08:43:59 -0700 | [diff] [blame] | 9 | Connection Configuration |
| 10 | ------------------------ |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 11 | |
James E. Blair | 83786d4 | 2017-08-04 08:43:59 -0700 | [diff] [blame] | 12 | The connection options for the SQL driver are: |
| 13 | |
| 14 | .. attr:: <sql connection> |
| 15 | |
| 16 | .. attr:: driver |
| 17 | :required: |
| 18 | |
| 19 | .. value:: sql |
| 20 | |
| 21 | The connection must set ``driver=sql`` for SQL connections. |
| 22 | |
| 23 | .. attr:: dburi |
| 24 | :required: |
| 25 | |
| 26 | Database connection information in the form of a URI understood |
| 27 | by SQLAlchemy. See `The SQLAlchemy manual |
| 28 | <http://docs.sqlalchemy.org/en/rel_1_0/core/engines.html#database-urls>`_ |
| 29 | for more information. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 30 | |
Joshua Hesketh | 7ab7c63 | 2017-10-16 15:03:26 +1100 | [diff] [blame] | 31 | The driver will automatically set up the database creating and managing |
| 32 | the necesssary tables. Therefore the provided user should have sufficient |
| 33 | permissions to manage the database. For example: |
| 34 | |
| 35 | .. code-block:: sql |
| 36 | |
| 37 | GRANT ALL ON my_database TO 'my_user'@'%'; |
| 38 | |
Joshua Hesketh | 9322b0e | 2017-10-16 15:09:48 +1100 | [diff] [blame] | 39 | .. attr:: pool_recycle |
| 40 | :default: 1 |
| 41 | |
| 42 | Tune the pool_recycle value. See `The SQLAlchemy manual on pooling |
| 43 | <http://docs.sqlalchemy.org/en/latest/core/pooling.html#setting-pool-recycle>`_ |
| 44 | for more information. |
| 45 | |
Tobias Henkel | 94a1d08 | 2017-12-09 12:24:52 +0100 | [diff] [blame] | 46 | .. attr:: table_prefix |
| 47 | :default: '' |
| 48 | |
| 49 | The string to prefix the table names. This makes it possible to run |
| 50 | several zuul deployments against the same database. This can be useful |
| 51 | if you rely on external databases which you don't have under control. |
| 52 | The default is to have no prefix. |
| 53 | |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 54 | Reporter Configuration |
| 55 | ---------------------- |
| 56 | |
| 57 | This reporter is used to store results in a database. |
| 58 | |
| 59 | A :ref:`connection<connections>` that uses the sql driver must be |
| 60 | supplied to the reporter. |
| 61 | |
James E. Blair | 83786d4 | 2017-08-04 08:43:59 -0700 | [diff] [blame] | 62 | ``zuul.conf`` contains the database connection and credentials. To |
| 63 | store different reports in different databases you'll need to create a |
| 64 | new connection per database. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 65 | |
James E. Blair | 83786d4 | 2017-08-04 08:43:59 -0700 | [diff] [blame] | 66 | The SQL reporter does nothing on :attr:`pipeline.start` or |
| 67 | :attr:`pipeline.merge-failure`; it only acts on |
| 68 | :attr:`pipeline.success` or :attr:`pipeline.failure` reporting stages. |
| 69 | |
| 70 | For example: |
| 71 | |
| 72 | .. code-block:: yaml |
| 73 | |
| 74 | - pipeline: |
| 75 | name: post-merge |
| 76 | success: |
James E. Blair | d5e2956 | 2017-08-04 09:48:59 -0700 | [diff] [blame] | 77 | mydb_conn: |
James E. Blair | 83786d4 | 2017-08-04 08:43:59 -0700 | [diff] [blame] | 78 | failure: |
James E. Blair | d5e2956 | 2017-08-04 09:48:59 -0700 | [diff] [blame] | 79 | mydb_conn: |
James E. Blair | 83786d4 | 2017-08-04 08:43:59 -0700 | [diff] [blame] | 80 | |
| 81 | .. attr:: pipeline.<reporter>.<sql source> |
| 82 | |
James E. Blair | d5e2956 | 2017-08-04 09:48:59 -0700 | [diff] [blame] | 83 | To report to a database, add a key with the connection name and an |
| 84 | empty value to the desired pipeline :ref:`reporter<reporters>` |
| 85 | attributes. |