logo250 Sqlite for LibreOffice on Windows

Adds sqlite3 support to LibreOffice on Windows.

Base Calc Draw Impress Macro Presentations Writer
Download latest

latest release: 2024-03-21 11:13:15

Description

Description

The sqlite3 module is a powerful part of the Python standard library; it lets us work with a fully featured on-disk SQL database without installing any additional software.

This extension adds sqlite3 support to LibreOffice on Windows.

 

Example

The demo create a database in the user's home directory called test.db and creates a table called fish with three columns: name, species, and tank_number. It then adds two rows of data to the table, and then reads the data back out. It then modifies the data in the table, and then deletes one of the rows.

>>> from sql_util import SqlCtx
>>> from pathlib import Path
>>> cs = Path.home() / "Documents/test.db"

# Creating a Connection to a SQLite Database
>>> with SqlCtx(cs) as db:
...     print(db.connection.total_changes)
... 
0

# Creating a table in the database
>>> with SqlCtx(cs) as db:
...     _ = db.cursor.execute("CREATE TABLE fish (name TEXT, species TEXT, tank_number INTEGER)")
... 


# Adding Data to the SQLite Database
>>> with SqlCtx(cs) as db:
...     with db.connection:
...         _ = db.cursor.execute("INSERT INTO fish VALUES ('Sammy', 'shark', 1)")
...         _ = db.cursor.execute("INSERT INTO fish VALUES ('Jamie', 'cuttlefish', 7)")
...     print(db.connection.total_changes)
... 
2

# Reading Data from the SQLite Database
>>> with SqlCtx(cs) as db:
...     rows = db.cursor.execute("SELECT name, species, tank_number FROM fish").fetchall()
...     for row in rows:
...         for key in row.keys():
...             print(f"{key} = {row[key]}")
... 
name = Sammy
species = shark
tank_number = 1
name = Jamie
species = cuttlefish
tank_number = 7

>>> with SqlCtx(cs) as db:
...     target_fish_name = "Jamie"
...     rows = db.cursor.execute(
...         "SELECT name, species, tank_number FROM fish WHERE name = ?",
...         (target_fish_name,),
...     ).fetchall()
...     for row in rows:
...         for key in row.keys():
...             print(f"{key} = {row[key]}")
... 
name = Jamie
species = cuttlefish
tank_number = 7


# Modifying Data in the SQLite Database
>>> with SqlCtx(cs) as db:
...     new_tank_number = 2
...     moved_fish_name = "Sammy"
...     with db.connection:
...         _ = db.cursor.execute("UPDATE fish SET tank_number = ? WHERE name = ?", (new_tank_number, moved_fish_name))
...         rows = db.cursor.execute("SELECT name, species, tank_number FROM fish").fetchall()
...         for row in rows:
...             for key in row.keys():
...                 print(f"{key} = {row[key]}")
... 
name = Sammy
species = shark
tank_number = 2
name = Jamie
species = cuttlefish
tank_number = 7


# Deleting Data from the SQLite Database
>>> with SqlCtx(cs) as db:
...     target_fish_name = "Sammy"
...     with db.connection:
...         _= db.cursor.execute("DELETE FROM fish WHERE name = ?", (target_fish_name,))
...         rows = db.cursor.execute("SELECT name, species, tank_number FROM fish").fetchall()
...         for row in rows:
...             for key in row.keys():
...                 print(f"{key} = {row[key]}")
... 
name = Jamie
species = cuttlefish
tank_number = 7

 

 

Homepage: https://github.com/Amourspirit/python-libreoffice-sqlite3-win-ext#readme

Repository: https://github.com/Amourspirit/python-libreoffice-sqlite3-win-ext

Release List

Release Description Compatibility Operating Systems License Release notes   1.0.3 startup fix 7.0 Windows MIT

Minor fix for startup dialog

Download 1.0.0 Initial Release 7.0 Windows MIT

Initial Release

Download

Other Extensions

OOO Development Tools (OooDev)

This project brings to power of OOO Development Tools (OooDev) to LibreOffice as an extension.

04-2024

2716

Not rated yet

Python Numpy Extension for LibreOffice

Numpy is The fundamental package for scientific computing with Python.This is a LibreOffice extension that allows you to use Numpy in LibreOffice python macros and scripts.&

04-2024

1293

Not rated yet

Include Python Path for LibreOffice

Give the ability to include external python paths in LibreOffice. Making other python packages available in Python macros and scripts.

04-2024

1080

Not rated yet

Pandas for LibreOffice

Pandas is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool, built on top of the Python programming language.

04-2024

1336

★ ★ ★ ★ ★

Sqlite for LibreOffice on Windows

Adds sqlite3 support to LibreOffice on Windows.

04-2024

1802

Not rated yet

Feedback

☆ ☆ ☆ ☆ ☆

Post your review

You cannot post reviews until you have logged in. Login Here.

Reviews

No one has commented on this page yet.

RSS feed for reviews on this page | RSS feed for all reviews