File: save.rst

package info (click to toggle)
python-agate 1.13.0-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,008 kB
  • sloc: python: 8,578; makefile: 126
file content (35 lines) | stat: -rw-r--r-- 532 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
============
Save a table
============

To a CSV
========

.. code-block:: python

    table.to_csv('filename.csv')

To JSON
=======

.. code-block:: python

    table.to_json('filename.json')

To newline-delimited JSON
=========================

.. code-block:: python

    table.to_json('filename.json', newline=True)

To a SQL database
=================

Use the `agate-sql <https://agate-sql.readthedocs.org/>`_ extension.

.. code-block:: python

    import agatesql

    table.to_sql('postgresql:///database', 'output_table')