Skip to main content

RemoteSqlite

RemoteSqlite is a way to easily access a remote Sqlite database and perform queries, including SELECT and INSERT operations

The remote database is referenced through a PyFilesystem2 url, such as:

  • osfs://path/to/file
  • s3://path/to/file

You can perform pull and push operations that transfer the database to a local temp directory

See below for examples of how to use

from remote_sqlite import RemoteSqlite
db = RemoteSqlite('osfs:///Users/vbalasubramaniam/Downloads/Northwind_large.sqlite', always_download=True)
db.get_counts()
[{'Employee': 9},
 {'Category': 8},
 {'Customer': 91},
 {'Shipper': 3},
 {'Supplier': 29},
 {'Order': 16818},
 {'Product': 77},
 {'OrderDetail': 621883},
 {'CustomerCustomerDemo': 0},
 {'CustomerDemographic': 0},
 {'Region': 4},
 {'Territory': 53},
 {'EmployeeTerritory': 49},
 {'posts': 0},
 {'posts_data': 2},
 {'posts_idx': 0},
 {'posts_content': 0},
 {'posts_docsize': 0},
 {'posts_config': 1},
 {'order_search': 16818},
 {'order_search_data': 226},
 {'order_search_idx': 474},
 {'order_search_content': 16818},
 {'order_search_docsize': 16818},
 {'order_search_config': 1}]
db.select("""SELECT * FROM Shipper""")
[{'Id': 1, 'CompanyName': 'Speedy Express', 'Phone': '(503) 555-9831'},
 {'Id': 2, 'CompanyName': 'United Package', 'Phone': '(503) 555-3199'},
 {'Id': 3, 'CompanyName': 'Federal Shipping', 'Phone': '(503) 555-9931'}]
new_records = [{'Id': 4, 'CompanyName': 'Speedy Express', 'Phone': '(503) 555-9831'},
 {'Id': 5, 'CompanyName': 'United Package', 'Phone': '(503) 555-3199'},
 {'Id': 6, 'CompanyName': 'Federal Shipping', 'Phone': '(503) 555-9931'}]
db.insert('Shipper', new_records)
db.con.execute('DELETE FROM Shipper WHERE Id >3')
<sqlite3.Cursor at 0x10535bab0>
create_statement = """CREATE TABLE test (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name TEXT,
  t TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)"""
db.con.execute(create_statement)
<sqlite3.Cursor at 0x1053a43b0>
db.insert('test', [{'name': 'John'},{'name':'Matt'}])
db.select('SELECT * FROM test')
[{'id': 1, 'name': 'John', 't': datetime.datetime(2020, 3, 7, 22, 12, 45)},
 {'id': 2, 'name': 'Matt', 't': datetime.datetime(2020, 3, 7, 22, 12, 45)}]
db.con.execute('DROP TABLE test')
<sqlite3.Cursor at 0x1053a42d0>
db.generate_create_table('Shipper2', [{'Id': 1, 'CompanyName': 'Speedy Express', 'Phone': '(503) 555-9831'},
 {'Id': 2, 'CompanyName': 'United Package', 'Phone': '(503) 555-3199'},
 {'Id': 3, 'CompanyName': 'Federal Shipping', 'Phone': '(503) 555-9931'}])
'CREATE TABLE "Shipper2" ("Id" TEXT, "CompanyName" TEXT, "Phone" TEXT)'
db.con.execute('CREATE TABLE "Shipper2" ("Id" TEXT, "CompanyName" TEXT, "Phone" TEXT)')
<sqlite3.Cursor at 0x1053a4340>
db.insert('Shipper2', [{'Id': 1, 'CompanyName': 'Speedy Express', 'Phone': '(503) 555-9831'},
 {'Id': 2, 'CompanyName': 'United Package', 'Phone': '(503) 555-3199'},
 {'Id': 3, 'CompanyName': 'Federal Shipping', 'Phone': '(503) 555-9931'}])
db.select('SELECT * FROM Shipper2')
[{'Id': '1', 'CompanyName': 'Speedy Express', 'Phone': '(503) 555-9831'},
 {'Id': '2', 'CompanyName': 'United Package', 'Phone': '(503) 555-3199'},
 {'Id': '3', 'CompanyName': 'Federal Shipping', 'Phone': '(503) 555-9931'}]

Download files

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

Source Distribution

remote_sqlite-1.1.1.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file remote_sqlite-1.1.1.tar.gz.

File metadata

  • Download URL: remote_sqlite-1.1.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.4.2 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for remote_sqlite-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f578f0f53332d6c9088513326431821532c1a98c48eec7f311979aee3486b2e9
MD5 a2b34937b778e4c02196d78c5345ec56
BLAKE2b-256 b7d73c4370a881beb75c7a8cfe5ee365cacac0b96b236e7761cfe45f5a7a02c5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.1 This release

1 file

1.1

1 file

1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page