File: save.rst

package info (click to toggle)
python-agate 1.6.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,976 kB
  • sloc: python: 9,093; makefile: 126
file content (35 lines) | stat: -rw-r--r-- 531 bytes parent folder | download | duplicates (3)
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 <http://agate-sql.readthedocs.org/>`_ extension.

.. code-block:: python

    import agatesql

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