Skip to main content

Single function that allows to save any sqlite3 database one to another. You can use this for example for loading and dumping memory database (:memory:) into file (alternative to iter dump functionality).

See the Sqlite3 C API docs for more info.

The same functionality is being provided by the apsw backup API, which provides even more information about the copy process.

Build and installation

Now you can build or install sqlitebck using distutils:

$ python setup.py build
$ python setup.py install

You can also intsall it, using the pip command:

$ pip install sqlitebck

Tests

Nothing big, just test basic functionality (make sure you have build the sqlitebck module):

$ python tests.py

Usage example

Basic usage example - memory database saved into file:

>>> import sqlite3
>>> conn = sqlite3.connect(':memory:')
>>> curr = conn.cursor()

Create table and put there some data:

>>> curr.execute('CREATE TABLE foo (bar INTEGER)')
<sqlite3.Cursor object at 0xb73b2800>
>>> curr.execute('INSERT INTO foo VALUES (123)')
<sqlite3.Cursor object at 0xb73b2800>
>>> curr.close()
>>> conn.commit()
>>> import sqlitebck

Save in memory database (conn) into file:

>>> conn2 = sqlite3.connect('/tmp/in_memory_sqlite_db_save.db')
>>> sqlitebck.copy(conn, conn2)
>>> conn.close()
>>> curr2 = conn2.cursor()

Check if data is in file database:

>>> curr2.execute('SELECT * FROM foo');
<sqlite3.Cursor object at 0xb73b2860>
>>> curr2.fetchall()
[(123,)]

If you want to load file database into memory, just call:

>>> sqlitebck.copy(conn2, conn)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlitebck-1.2.1.tar.gz (6.4 kB view details)

Uploaded Source

File details

Details for the file sqlitebck-1.2.1.tar.gz.

File metadata

  • Download URL: sqlitebck-1.2.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sqlitebck-1.2.1.tar.gz
Algorithm Hash digest
SHA256 a870a0a3efcbf2d43d2074c01ae76611ea735ed9b5b578d92afa30edd70f6ed8
MD5 3b094b07e651196a57bee431841594ec
BLAKE2b-256 37e4580395c41604134a0a21b41d8558df8b9896955e7a90697eec77224f6848

See more details on using hashes here.

Release history Release notifications | RSS feed

1.4

1 file

1.3

1 file

This release

1.2.1 This release

1 file

1.2

1 file

1.1

1 file

1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page