python-sqlite3-backup

Software Screenshot:
python-sqlite3-backup
Software Details:
Version: 1.0
Upload Date: 14 Apr 15
Developer: Piotr Husiatynski
Distribution Type: Freeware
Downloads: 24

Rating: 4.0/5 (Total Votes: 1)

sqlitebck is a 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.

Build and installation

Now you can build or install sqlitebck using distutils:

 python setup.py install

Tests

Nothing big, just test basic functionality:

 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)

Requirements:

  • Python

Similar Software

DBKiss
DBKiss

11 May 15

PgAdmin III
PgAdmin III

17 Feb 15

Reportico
Reportico

19 Feb 15

Qore JSON Module
Qore JSON Module

19 Feb 15

Other Software of Developer Piotr Husiatynski

256-jungle
256-jungle

2 Jun 15

sqlitebck
sqlitebck

6 Jun 15

Comments to python-sqlite3-backup

Comments not found
Add Comment
Turn on images!