SimpleSQLite


NameSimpleSQLite JSON
Version 1.5.2 PyPI version JSON
download
home_pagehttps://github.com/thombashi/SimpleSQLite
SummarySimpleSQLite is a Python library to simplify SQLite database operations: table creation, data insertion and get data as other data formats. Simple ORM functionality for SQLite.
upload_time2023-12-01 15:44:15
maintainer
docs_urlNone
authorTsuyoshi Hombashi
requires_python>=3.7
licenseMIT License
keywords sqlite csv google sheets json
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. contents:: **SimpleSQLite**
   :backlinks: top
   :depth: 2

Summary
=========
`SimpleSQLite <https://github.com/thombashi/SimpleSQLite>`__ is a Python library to simplify SQLite database operations: table creation, data insertion and get data as other data formats. Simple ORM functionality for SQLite.

.. image:: https://badge.fury.io/py/SimpleSQLite.svg
    :target: https://badge.fury.io/py/SimpleSQLite
    :alt: PyPI package version

.. image:: https://img.shields.io/pypi/pyversions/SimpleSQLite.svg
    :target: https://pypi.org/project/SimpleSQLite
    :alt: Supported Python versions

.. image:: https://img.shields.io/pypi/implementation/SimpleSQLite.svg
    :target: https://pypi.org/project/SimpleSQLite
    :alt: Supported Python implementations

.. image:: https://github.com/thombashi/SimpleSQLite/actions/workflows/ci.yml/badge.svg
    :target: https://github.com/thombashi/SimpleSQLite/actions/workflows/ci.yml
    :alt: CI status of Linux/macOS/Windows

.. image:: https://github.com/thombashi/SimpleSQLite/actions/workflows/github-code-scanning/codeql/badge.svg
    :target: https://github.com/thombashi/SimpleSQLite/actions/workflows/github-code-scanning/codeql
    :alt: CodeQL

.. image:: https://coveralls.io/repos/github/thombashi/SimpleSQLite/badge.svg?branch=master
    :target: https://coveralls.io/github/thombashi/SimpleSQLite?branch=master
    :alt: Test coverage

Features
--------
- Automated SQLite table creation from data
- Support various data types of record(s) insertion into a table:
    - ``dict``
    - ``namedtuple``
    - ``list``
    - ``tuple``
- Create table(s) from:
    - CSV file/text
    - JSON file/text
    - `pandas.DataFrame <https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html>`__ instance
    - `tabledata.TableData <https://tabledata.readthedocs.io/en/latest/pages/reference/data.html>`__ instance loaded by `pytablereader <https://github.com/thombashi/pytablereader>`__
- Get data from a table as:
    - `pandas.DataFrame <https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html>`__ instance
    - `tabledata.TableData <https://github.com/thombashi/tabledata>`__ instance
- Simple object-relational mapping (ORM) functionality

Examples
==========
Create a table
----------------
Create a table from a data matrix
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:Sample Code:
    .. code-block:: python

        from simplesqlite import SimpleSQLite


        table_name = "sample_table"
        con = SimpleSQLite("sample.sqlite", "w")

        # create table -----
        data_matrix = [[1, 1.1, "aaa", 1, 1], [2, 2.2, "bbb", 2.2, 2.2], [3, 3.3, "ccc", 3, "ccc"]]
        con.create_table_from_data_matrix(
            table_name,
            ["attr_a", "attr_b", "attr_c", "attr_d", "attr_e"],
            data_matrix,
        )

        # display data type for each column in the table -----
        print(con.schema_extractor.fetch_table_schema(table_name).dumps())

        # display values in the table -----
        print("records:")
        result = con.select(select="*", table_name=table_name)
        for record in result.fetchall():
            print(record)

:Output:
    .. code-block::

        .. table:: sample_table

            +---------+-------+-----------+--------+------+-----+
            |Attribute| Type  |PRIMARY KEY|NOT NULL|UNIQUE|Index|
            +=========+=======+===========+========+======+=====+
            |attr_a   |INTEGER|           |        |      |     |
            +---------+-------+-----------+--------+------+-----+
            |attr_b   |REAL   |           |        |      |     |
            +---------+-------+-----------+--------+------+-----+
            |attr_c   |TEXT   |           |        |      |     |
            +---------+-------+-----------+--------+------+-----+
            |attr_d   |REAL   |           |        |      |     |
            +---------+-------+-----------+--------+------+-----+
            |attr_e   |TEXT   |           |        |      |     |
            +---------+-------+-----------+--------+------+-----+


        records:
        (1, 1.1, 'aaa', 1.0, '1')
        (2, 2.2, 'bbb', 2.2, '2.2')
        (3, 3.3, 'ccc', 3.0, 'ccc')

Create a table from CSV
~~~~~~~~~~~~~~~~~~~~~~~~~
:Sample Code:
    .. code-block:: python

        from simplesqlite import SimpleSQLite

        with open("sample_data.csv", "w") as f:
            f.write("\n".join([
                '"attr_a","attr_b","attr_c"',
                '1,4,"a"',
                '2,2.1,"bb"',
                '3,120.9,"ccc"',
            ]))

        # create table ---
        con = SimpleSQLite("sample.sqlite", "w")
        con.create_table_from_csv("sample_data.csv")

        # output ---
        table_name = "sample_data"
        print(con.fetch_attr_names(table_name))
        result = con.select(select="*", table_name=table_name)
        for record in result.fetchall():
            print(record)

:Output:
    .. code-block::

        ['attr_a', 'attr_b', 'attr_c']
        (1, 4.0, 'a')
        (2, 2.1, 'bb')
        (3, 120.9, 'ccc')

Create a table from pandas.DataFrame
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:Sample Code:
    .. code-block:: python

        from simplesqlite import SimpleSQLite
        import pandas

        con = SimpleSQLite("pandas_df.sqlite")

        con.create_table_from_dataframe(pandas.DataFrame(
            [
                [0, 0.1, "a"],
                [1, 1.1, "bb"],
                [2, 2.2, "ccc"],
            ],
            columns=['id', 'value', 'name']
        ), table_name="pandas_df")

:Output:
    .. code-block:: sql

        $ sqlite3 pandas_df.sqlite
        sqlite> .schema
        CREATE TABLE 'pandas_df' (id INTEGER, value REAL, name TEXT);

Insert records into a table
-----------------------------
Insert dictionary
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Sample Code:
    .. code-block:: python

        from simplesqlite import SimpleSQLite

        table_name = "sample_table"
        con = SimpleSQLite("sample.sqlite", "w")
        con.create_table_from_data_matrix(
            table_name,
            ["attr_a", "attr_b", "attr_c", "attr_d", "attr_e"],
            [[1, 1.1, "aaa", 1,   1]])

        con.insert(
            table_name,
            record={
                "attr_a": 4,
                "attr_b": 4.4,
                "attr_c": "ddd",
                "attr_d": 4.44,
                "attr_e": "hoge",
            })
        con.insert_many(
            table_name,
            records=[
                {
                    "attr_a": 5,
                    "attr_b": 5.5,
                    "attr_c": "eee",
                    "attr_d": 5.55,
                    "attr_e": "foo",
                },
                {
                    "attr_a": 6,
                    "attr_c": "fff",
                },
            ])

        result = con.select(select="*", table_name=table_name)
        for record in result.fetchall():
            print(record)

:Output:
    .. code-block::

        (1, 1.1, 'aaa', 1, 1)
        (4, 4.4, 'ddd', 4.44, 'hoge')
        (5, 5.5, 'eee', 5.55, 'foo')
        (6, None, 'fff', None, None)


Insert list/tuple/namedtuple
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Sample Code:
    .. code-block:: python

        from collections import namedtuple
        from simplesqlite import SimpleSQLite

        table_name = "sample_table"
        con = SimpleSQLite("sample.sqlite", "w")
        con.create_table_from_data_matrix(
            table_name,
            ["attr_a", "attr_b", "attr_c", "attr_d", "attr_e"],
            [[1, 1.1, "aaa", 1, 1]],
        )

        # insert namedtuple
        SampleTuple = namedtuple("SampleTuple", "attr_a attr_b attr_c attr_d attr_e")

        con.insert(table_name, record=[7, 7.7, "fff", 7.77, "bar"])
        con.insert_many(
            table_name,
            records=[(8, 8.8, "ggg", 8.88, "foobar"), SampleTuple(9, 9.9, "ggg", 9.99, "hogehoge")],
        )

        # print
        result = con.select(select="*", table_name=table_name)
        for record in result.fetchall():
            print(record)

:Output:
    .. code-block::

        (1, 1.1, 'aaa', 1, 1)
        (7, 7.7, 'fff', 7.77, 'bar')
        (8, 8.8, 'ggg', 8.88, 'foobar')
        (9, 9.9, 'ggg', 9.99, 'hogehoge')

Fetch data from a table as pandas DataFrame
---------------------------------------------
:Sample Code:
    .. code-block:: python

        from simplesqlite import SimpleSQLite

        con = SimpleSQLite("sample.sqlite", "w", profile=True)

        con.create_table_from_data_matrix(
            "sample_table",
            ["a", "b", "c", "d", "e"],
            [
                [1, 1.1, "aaa", 1,   1],
                [2, 2.2, "bbb", 2.2, 2.2],
                [3, 3.3, "ccc", 3,   "ccc"],
            ])

        print(con.select_as_dataframe(table_name="sample_table"))

:Output:
    .. code-block::

        $ sample/select_as_dataframe.py
           a    b    c    d    e
        0  1  1.1  aaa  1.0    1
        1  2  2.2  bbb  2.2  2.2
        2  3  3.3  ccc  3.0  ccc

ORM functionality
-------------------
:Sample Code:
    .. code-block:: python

        from simplesqlite import connect_memdb
        from simplesqlite.model import Integer, Model, Real, Text


        class Sample(Model):
            foo_id = Integer(primary_key=True)
            name = Text(not_null=True, unique=True)
            value = Real(default=0)


        def main() -> None:
            con = connect_memdb()

            Sample.attach(con)
            Sample.create()
            Sample.insert(Sample(name="abc", value=0.1))
            Sample.insert(Sample(name="xyz", value=1.11))
            Sample.insert(Sample(name="bar"))

            print(Sample.fetch_schema().dumps())
            print("records:")
            for record in Sample.select():
                print(f"    {record}")


        if __name__ == "__main__":
            main()

:Output:
    .. code-block::

        .. table:: sample

            +--------+---------+----------+-----+---------+-------+-------+
            | Field  |  Type   | Nullable | Key | Default | Index | Extra |
            +========+=========+==========+=====+=========+=======+=======+
            | foo_id | INTEGER | YES      | PRI | NULL    |   X   |       |
            +--------+---------+----------+-----+---------+-------+-------+
            | name   | TEXT    | NO       | UNI |         |   X   |       |
            +--------+---------+----------+-----+---------+-------+-------+
            | value  | REAL    | YES      |     | 0       |       |       |
            +--------+---------+----------+-----+---------+-------+-------+

        records:
            Sample (foo_id=1, name=abc, value=0.1)
            Sample (foo_id=2, name=xyz, value=1.11)
            Sample (foo_id=3, name=bar, value=0.0)

For more information
----------------------
More examples are available at 
https://simplesqlite.rtfd.io/en/latest/pages/examples/index.html

Installation
============
Install from PyPI
------------------------------
::

    pip install SimpleSQLite

Install from PPA (for Ubuntu)
------------------------------
::

    sudo add-apt-repository ppa:thombashi/ppa
    sudo apt update
    sudo apt install python3-simplesqlite


Dependencies
============
- Python 3.7+
- `Python package dependencies (automatically installed) <https://github.com/thombashi/SimpleSQLite/network/dependencies>`__

Optional Dependencies
----------------------------------
- `loguru <https://github.com/Delgan/loguru>`__
    - Used for logging if the package installed
- `pandas <https://pandas.pydata.org/>`__
- `pytablereader <https://github.com/thombashi/pytablereader>`__

Documentation
===============
https://simplesqlite.rtfd.io/

Related Project
=================
- `sqlitebiter <https://github.com/thombashi/sqlitebiter>`__: CLI tool to convert CSV/Excel/HTML/JSON/LTSV/Markdown/TSV/Google-Sheets SQLite database by using SimpleSQLite

Sponsors
====================================
.. image:: https://avatars.githubusercontent.com/u/44389260?s=48&u=6da7176e51ae2654bcfd22564772ef8a3bb22318&v=4
   :target: https://github.com/chasbecker
   :alt: Charles Becker (chasbecker)
.. image:: https://avatars.githubusercontent.com/u/46711571?s=48&u=57687c0e02d5d6e8eeaf9177f7b7af4c9f275eb5&v=4
   :target: https://github.com/Arturi0
   :alt: onetime: Arturi0
.. image:: https://avatars.githubusercontent.com/u/3658062?s=48&v=4
   :target: https://github.com/b4tman
   :alt: onetime: Dmitry Belyaev (b4tman)

`Become a sponsor <https://github.com/sponsors/thombashi>`__


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/thombashi/SimpleSQLite",
    "name": "SimpleSQLite",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "SQLite,CSV,Google Sheets,JSON",
    "author": "Tsuyoshi Hombashi",
    "author_email": "tsuyoshi.hombashi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c8/07/92e3291fda6f1bbf6e7ff4721d87566e1615572d9c205ef64398c5d22efe/SimpleSQLite-1.5.2.tar.gz",
    "platform": null,
    "description": ".. contents:: **SimpleSQLite**\n   :backlinks: top\n   :depth: 2\n\nSummary\n=========\n`SimpleSQLite <https://github.com/thombashi/SimpleSQLite>`__ is a Python library to simplify SQLite database operations: table creation, data insertion and get data as other data formats. Simple ORM functionality for SQLite.\n\n.. image:: https://badge.fury.io/py/SimpleSQLite.svg\n    :target: https://badge.fury.io/py/SimpleSQLite\n    :alt: PyPI package version\n\n.. image:: https://img.shields.io/pypi/pyversions/SimpleSQLite.svg\n    :target: https://pypi.org/project/SimpleSQLite\n    :alt: Supported Python versions\n\n.. image:: https://img.shields.io/pypi/implementation/SimpleSQLite.svg\n    :target: https://pypi.org/project/SimpleSQLite\n    :alt: Supported Python implementations\n\n.. image:: https://github.com/thombashi/SimpleSQLite/actions/workflows/ci.yml/badge.svg\n    :target: https://github.com/thombashi/SimpleSQLite/actions/workflows/ci.yml\n    :alt: CI status of Linux/macOS/Windows\n\n.. image:: https://github.com/thombashi/SimpleSQLite/actions/workflows/github-code-scanning/codeql/badge.svg\n    :target: https://github.com/thombashi/SimpleSQLite/actions/workflows/github-code-scanning/codeql\n    :alt: CodeQL\n\n.. image:: https://coveralls.io/repos/github/thombashi/SimpleSQLite/badge.svg?branch=master\n    :target: https://coveralls.io/github/thombashi/SimpleSQLite?branch=master\n    :alt: Test coverage\n\nFeatures\n--------\n- Automated SQLite table creation from data\n- Support various data types of record(s) insertion into a table:\n    - ``dict``\n    - ``namedtuple``\n    - ``list``\n    - ``tuple``\n- Create table(s) from:\n    - CSV file/text\n    - JSON file/text\n    - `pandas.DataFrame <https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html>`__ instance\n    - `tabledata.TableData <https://tabledata.readthedocs.io/en/latest/pages/reference/data.html>`__ instance loaded by `pytablereader <https://github.com/thombashi/pytablereader>`__\n- Get data from a table as:\n    - `pandas.DataFrame <https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html>`__ instance\n    - `tabledata.TableData <https://github.com/thombashi/tabledata>`__ instance\n- Simple object-relational mapping (ORM) functionality\n\nExamples\n==========\nCreate a table\n----------------\nCreate a table from a data matrix\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n    .. code-block:: python\n\n        from simplesqlite import SimpleSQLite\n\n\n        table_name = \"sample_table\"\n        con = SimpleSQLite(\"sample.sqlite\", \"w\")\n\n        # create table -----\n        data_matrix = [[1, 1.1, \"aaa\", 1, 1], [2, 2.2, \"bbb\", 2.2, 2.2], [3, 3.3, \"ccc\", 3, \"ccc\"]]\n        con.create_table_from_data_matrix(\n            table_name,\n            [\"attr_a\", \"attr_b\", \"attr_c\", \"attr_d\", \"attr_e\"],\n            data_matrix,\n        )\n\n        # display data type for each column in the table -----\n        print(con.schema_extractor.fetch_table_schema(table_name).dumps())\n\n        # display values in the table -----\n        print(\"records:\")\n        result = con.select(select=\"*\", table_name=table_name)\n        for record in result.fetchall():\n            print(record)\n\n:Output:\n    .. code-block::\n\n        .. table:: sample_table\n\n            +---------+-------+-----------+--------+------+-----+\n            |Attribute| Type  |PRIMARY KEY|NOT NULL|UNIQUE|Index|\n            +=========+=======+===========+========+======+=====+\n            |attr_a   |INTEGER|           |        |      |     |\n            +---------+-------+-----------+--------+------+-----+\n            |attr_b   |REAL   |           |        |      |     |\n            +---------+-------+-----------+--------+------+-----+\n            |attr_c   |TEXT   |           |        |      |     |\n            +---------+-------+-----------+--------+------+-----+\n            |attr_d   |REAL   |           |        |      |     |\n            +---------+-------+-----------+--------+------+-----+\n            |attr_e   |TEXT   |           |        |      |     |\n            +---------+-------+-----------+--------+------+-----+\n\n\n        records:\n        (1, 1.1, 'aaa', 1.0, '1')\n        (2, 2.2, 'bbb', 2.2, '2.2')\n        (3, 3.3, 'ccc', 3.0, 'ccc')\n\nCreate a table from CSV\n~~~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n    .. code-block:: python\n\n        from simplesqlite import SimpleSQLite\n\n        with open(\"sample_data.csv\", \"w\") as f:\n            f.write(\"\\n\".join([\n                '\"attr_a\",\"attr_b\",\"attr_c\"',\n                '1,4,\"a\"',\n                '2,2.1,\"bb\"',\n                '3,120.9,\"ccc\"',\n            ]))\n\n        # create table ---\n        con = SimpleSQLite(\"sample.sqlite\", \"w\")\n        con.create_table_from_csv(\"sample_data.csv\")\n\n        # output ---\n        table_name = \"sample_data\"\n        print(con.fetch_attr_names(table_name))\n        result = con.select(select=\"*\", table_name=table_name)\n        for record in result.fetchall():\n            print(record)\n\n:Output:\n    .. code-block::\n\n        ['attr_a', 'attr_b', 'attr_c']\n        (1, 4.0, 'a')\n        (2, 2.1, 'bb')\n        (3, 120.9, 'ccc')\n\nCreate a table from pandas.DataFrame\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n    .. code-block:: python\n\n        from simplesqlite import SimpleSQLite\n        import pandas\n\n        con = SimpleSQLite(\"pandas_df.sqlite\")\n\n        con.create_table_from_dataframe(pandas.DataFrame(\n            [\n                [0, 0.1, \"a\"],\n                [1, 1.1, \"bb\"],\n                [2, 2.2, \"ccc\"],\n            ],\n            columns=['id', 'value', 'name']\n        ), table_name=\"pandas_df\")\n\n:Output:\n    .. code-block:: sql\n\n        $ sqlite3 pandas_df.sqlite\n        sqlite> .schema\n        CREATE TABLE 'pandas_df' (id INTEGER, value REAL, name TEXT);\n\nInsert records into a table\n-----------------------------\nInsert dictionary\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n:Sample Code:\n    .. code-block:: python\n\n        from simplesqlite import SimpleSQLite\n\n        table_name = \"sample_table\"\n        con = SimpleSQLite(\"sample.sqlite\", \"w\")\n        con.create_table_from_data_matrix(\n            table_name,\n            [\"attr_a\", \"attr_b\", \"attr_c\", \"attr_d\", \"attr_e\"],\n            [[1, 1.1, \"aaa\", 1,   1]])\n\n        con.insert(\n            table_name,\n            record={\n                \"attr_a\": 4,\n                \"attr_b\": 4.4,\n                \"attr_c\": \"ddd\",\n                \"attr_d\": 4.44,\n                \"attr_e\": \"hoge\",\n            })\n        con.insert_many(\n            table_name,\n            records=[\n                {\n                    \"attr_a\": 5,\n                    \"attr_b\": 5.5,\n                    \"attr_c\": \"eee\",\n                    \"attr_d\": 5.55,\n                    \"attr_e\": \"foo\",\n                },\n                {\n                    \"attr_a\": 6,\n                    \"attr_c\": \"fff\",\n                },\n            ])\n\n        result = con.select(select=\"*\", table_name=table_name)\n        for record in result.fetchall():\n            print(record)\n\n:Output:\n    .. code-block::\n\n        (1, 1.1, 'aaa', 1, 1)\n        (4, 4.4, 'ddd', 4.44, 'hoge')\n        (5, 5.5, 'eee', 5.55, 'foo')\n        (6, None, 'fff', None, None)\n\n\nInsert list/tuple/namedtuple\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n:Sample Code:\n    .. code-block:: python\n\n        from collections import namedtuple\n        from simplesqlite import SimpleSQLite\n\n        table_name = \"sample_table\"\n        con = SimpleSQLite(\"sample.sqlite\", \"w\")\n        con.create_table_from_data_matrix(\n            table_name,\n            [\"attr_a\", \"attr_b\", \"attr_c\", \"attr_d\", \"attr_e\"],\n            [[1, 1.1, \"aaa\", 1, 1]],\n        )\n\n        # insert namedtuple\n        SampleTuple = namedtuple(\"SampleTuple\", \"attr_a attr_b attr_c attr_d attr_e\")\n\n        con.insert(table_name, record=[7, 7.7, \"fff\", 7.77, \"bar\"])\n        con.insert_many(\n            table_name,\n            records=[(8, 8.8, \"ggg\", 8.88, \"foobar\"), SampleTuple(9, 9.9, \"ggg\", 9.99, \"hogehoge\")],\n        )\n\n        # print\n        result = con.select(select=\"*\", table_name=table_name)\n        for record in result.fetchall():\n            print(record)\n\n:Output:\n    .. code-block::\n\n        (1, 1.1, 'aaa', 1, 1)\n        (7, 7.7, 'fff', 7.77, 'bar')\n        (8, 8.8, 'ggg', 8.88, 'foobar')\n        (9, 9.9, 'ggg', 9.99, 'hogehoge')\n\nFetch data from a table as pandas DataFrame\n---------------------------------------------\n:Sample Code:\n    .. code-block:: python\n\n        from simplesqlite import SimpleSQLite\n\n        con = SimpleSQLite(\"sample.sqlite\", \"w\", profile=True)\n\n        con.create_table_from_data_matrix(\n            \"sample_table\",\n            [\"a\", \"b\", \"c\", \"d\", \"e\"],\n            [\n                [1, 1.1, \"aaa\", 1,   1],\n                [2, 2.2, \"bbb\", 2.2, 2.2],\n                [3, 3.3, \"ccc\", 3,   \"ccc\"],\n            ])\n\n        print(con.select_as_dataframe(table_name=\"sample_table\"))\n\n:Output:\n    .. code-block::\n\n        $ sample/select_as_dataframe.py\n           a    b    c    d    e\n        0  1  1.1  aaa  1.0    1\n        1  2  2.2  bbb  2.2  2.2\n        2  3  3.3  ccc  3.0  ccc\n\nORM functionality\n-------------------\n:Sample Code:\n    .. code-block:: python\n\n        from simplesqlite import connect_memdb\n        from simplesqlite.model import Integer, Model, Real, Text\n\n\n        class Sample(Model):\n            foo_id = Integer(primary_key=True)\n            name = Text(not_null=True, unique=True)\n            value = Real(default=0)\n\n\n        def main() -> None:\n            con = connect_memdb()\n\n            Sample.attach(con)\n            Sample.create()\n            Sample.insert(Sample(name=\"abc\", value=0.1))\n            Sample.insert(Sample(name=\"xyz\", value=1.11))\n            Sample.insert(Sample(name=\"bar\"))\n\n            print(Sample.fetch_schema().dumps())\n            print(\"records:\")\n            for record in Sample.select():\n                print(f\"    {record}\")\n\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. code-block::\n\n        .. table:: sample\n\n            +--------+---------+----------+-----+---------+-------+-------+\n            | Field  |  Type   | Nullable | Key | Default | Index | Extra |\n            +========+=========+==========+=====+=========+=======+=======+\n            | foo_id | INTEGER | YES      | PRI | NULL    |   X   |       |\n            +--------+---------+----------+-----+---------+-------+-------+\n            | name   | TEXT    | NO       | UNI |         |   X   |       |\n            +--------+---------+----------+-----+---------+-------+-------+\n            | value  | REAL    | YES      |     | 0       |       |       |\n            +--------+---------+----------+-----+---------+-------+-------+\n\n        records:\n            Sample (foo_id=1, name=abc, value=0.1)\n            Sample (foo_id=2, name=xyz, value=1.11)\n            Sample (foo_id=3, name=bar, value=0.0)\n\nFor more information\n----------------------\nMore examples are available at \nhttps://simplesqlite.rtfd.io/en/latest/pages/examples/index.html\n\nInstallation\n============\nInstall from PyPI\n------------------------------\n::\n\n    pip install SimpleSQLite\n\nInstall from PPA (for Ubuntu)\n------------------------------\n::\n\n    sudo add-apt-repository ppa:thombashi/ppa\n    sudo apt update\n    sudo apt install python3-simplesqlite\n\n\nDependencies\n============\n- Python 3.7+\n- `Python package dependencies (automatically installed) <https://github.com/thombashi/SimpleSQLite/network/dependencies>`__\n\nOptional Dependencies\n----------------------------------\n- `loguru <https://github.com/Delgan/loguru>`__\n    - Used for logging if the package installed\n- `pandas <https://pandas.pydata.org/>`__\n- `pytablereader <https://github.com/thombashi/pytablereader>`__\n\nDocumentation\n===============\nhttps://simplesqlite.rtfd.io/\n\nRelated Project\n=================\n- `sqlitebiter <https://github.com/thombashi/sqlitebiter>`__: CLI tool to convert CSV/Excel/HTML/JSON/LTSV/Markdown/TSV/Google-Sheets SQLite database by using SimpleSQLite\n\nSponsors\n====================================\n.. image:: https://avatars.githubusercontent.com/u/44389260?s=48&u=6da7176e51ae2654bcfd22564772ef8a3bb22318&v=4\n   :target: https://github.com/chasbecker\n   :alt: Charles Becker (chasbecker)\n.. image:: https://avatars.githubusercontent.com/u/46711571?s=48&u=57687c0e02d5d6e8eeaf9177f7b7af4c9f275eb5&v=4\n   :target: https://github.com/Arturi0\n   :alt: onetime: Arturi0\n.. image:: https://avatars.githubusercontent.com/u/3658062?s=48&v=4\n   :target: https://github.com/b4tman\n   :alt: onetime: Dmitry Belyaev (b4tman)\n\n`Become a sponsor <https://github.com/sponsors/thombashi>`__\n\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "SimpleSQLite is a Python library to simplify SQLite database operations: table creation, data insertion and get data as other data formats. Simple ORM functionality for SQLite.",
    "version": "1.5.2",
    "project_urls": {
        "Changlog": "https://github.com/thombashi/SimpleSQLite/releases",
        "Documentation": "https://SimpleSQLite.rtfd.io/",
        "Homepage": "https://github.com/thombashi/SimpleSQLite",
        "Source": "https://github.com/thombashi/SimpleSQLite",
        "Tracker": "https://github.com/thombashi/SimpleSQLite/issues"
    },
    "split_keywords": [
        "sqlite",
        "csv",
        "google sheets",
        "json"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f5d5f51ce79a7d07de6d3f684a07cc7554bfa7a0d3f4dbffe258e79e832c364b",
                "md5": "c95b5b223d7fbfa13d9a113af4b1f73a",
                "sha256": "f62300ce1e367fd5234a959fa3a32d7c81bdf719204ebc1e70c4f3cd91672dc6"
            },
            "downloads": -1,
            "filename": "SimpleSQLite-1.5.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c95b5b223d7fbfa13d9a113af4b1f73a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 33978,
            "upload_time": "2023-12-01T15:44:12",
            "upload_time_iso_8601": "2023-12-01T15:44:12.316765Z",
            "url": "https://files.pythonhosted.org/packages/f5/d5/f51ce79a7d07de6d3f684a07cc7554bfa7a0d3f4dbffe258e79e832c364b/SimpleSQLite-1.5.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c80792e3291fda6f1bbf6e7ff4721d87566e1615572d9c205ef64398c5d22efe",
                "md5": "a907352592539345bf8145c3e39015cb",
                "sha256": "f9a25b9e43d7aa28f551d170a42cfae10139c5c81a1bcb8776f857816ef5ae0f"
            },
            "downloads": -1,
            "filename": "SimpleSQLite-1.5.2.tar.gz",
            "has_sig": false,
            "md5_digest": "a907352592539345bf8145c3e39015cb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 60949,
            "upload_time": "2023-12-01T15:44:15",
            "upload_time_iso_8601": "2023-12-01T15:44:15.939442Z",
            "url": "https://files.pythonhosted.org/packages/c8/07/92e3291fda6f1bbf6e7ff4721d87566e1615572d9c205ef64398c5d22efe/SimpleSQLite-1.5.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-01 15:44:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "thombashi",
    "github_project": "SimpleSQLite",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "simplesqlite"
}
        
Elapsed time: 0.15120s