Skip to content

Commit

Permalink
Basic Documentation for
Browse files Browse the repository at this point in the history
runalyzer 'is_gathered' and upgrade_db 'upgrade_db' APIs
  • Loading branch information
EdgesFTW committed Dec 5, 2023
1 parent 0d5305c commit d13f944
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ API Documentation
=================

.. automodule:: logpyle
.. automodule:: logpyle.runalyzer
.. automodule:: logpyle.upgrade_db
15 changes: 15 additions & 0 deletions logpyle/runalyzer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#! /usr/bin/env python
"""
Runalyzer Functions
--------------------------------
.. autofunction:: is_gathered
"""

import code
import sqlite3
Expand Down Expand Up @@ -459,6 +464,16 @@ def my_sprintf(format: str, arg: str) -> str:


def is_gathered(conn: sqlite3.Connection) -> bool:
"""
The function checks whether a connection to an existing
database has been gathered.
Parameters
----------
conn
SQLite3 connection object
"""

gathered = False
# get a list of tables with the name of 'runs'
res = list(conn.execute("""
Expand Down
34 changes: 34 additions & 0 deletions logpyle/upgrade_db.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
Database Upgrade Functions
--------------------------------
.. autofunction:: upgrade_db
"""
import shutil
import sqlite3

Expand Down Expand Up @@ -58,6 +63,35 @@ def upgrade_conn(conn: sqlite3.Connection) -> sqlite3.Connection:
def upgrade_db(
dbfile: str, suffix: str, overwrite: bool
) -> None:
"""
The function first connects to the original database . If the
`overwrite` parameter is True, it simply modifies the existing
database and uses the same file name for the upgraded database.
Otherwise, a new database is created with a separate filename
by appending the given suffix to the original file's base name
using `filename + suffix + "." + file_ext`.
Next, the function prints a message indicating whether it is
overwriting or creating a new database and then proceeds to
upgrade the database schema version to 3.
Parameters
----------
name
Quantity name.
dbfile
A database file path
suffix
a suffix to be appended to the filename for the
upgraded database
overwrite
a boolean value indicating
whether to overwrite the original database or not
"""

# original db files
old_conn = sqlite3.connect(dbfile)
Expand Down

0 comments on commit d13f944

Please sign in to comment.