Skip to content

Commit

Permalink
update sqlite loading code
Browse files Browse the repository at this point in the history
clean up project files
  • Loading branch information
KeithKelleher committed May 30, 2024
1 parent 3c6bd05 commit b8b39d7
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 475 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ misc/output/
misc/jupyter/
conf/*db_props*

.idea
.idea
.venv
13 changes: 0 additions & 13 deletions .idea/RaMP.iml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

365 changes: 0 additions & 365 deletions .idea/workspace.xml

This file was deleted.

17 changes: 0 additions & 17 deletions .project

This file was deleted.

36 changes: 0 additions & 36 deletions .pydevproject

This file was deleted.

30 changes: 9 additions & 21 deletions main/mainSqliteDBLoad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import shutil
sys.path.append('../src')
from util.SQLiteDBBulkLoader import SQLiteDBBulkLoader

Expand All @@ -7,36 +8,23 @@
class mainSQLiteDBLoad(object):

def __init__(self):


# db login credentials and host info
# this is a private text file for login credentials
# Format:
# host=<host_uri>
# dbname=<db_name_usually_ramp>
# username=<db_user_name_often_root>
# conpass=<db_connection_password>
self.dbPropsFile = "../config/ramp_db_props.txt"

# config for tables to load
# a tab delimited file indicating which tables to load.
self.dbConfigFilePath = "../config/db_load_resource_config.txt"



def loadDBAfterTruncatingTables(self, sqliteFile, incrementLevel = 'increment_patch_release', optionalVersionOveride = None, optionalVersionNote = None, truncateTables = False, tablesToKeep=['db_version', 'version_info']):


################# DB Loading Instructions

def loadDBAfterTruncatingTables(self, schema_file='../schema/RaMP_SQLite_BASE.sqlite', incrementLevel = 'increment_patch_release', optionalVersionOveride = None, optionalVersionNote = None, truncateTables = False, tablesToKeep=['db_version', 'version_info']):

if optionalVersionOveride:
sqliteFile = schema_file.replace('BASE', f'v{optionalVersionOveride}')
shutil.copy(schema_file, sqliteFile)
################# DB Loading Instructions
# Sets logging level

# config file holds login credentials in this format:

# pass the credentials object to the constructed rampDBBulLoader

loader = SQLiteDBBulkLoader(dbPropsFile=self.dbPropsFile, sqliteFileName=sqliteFile)
loader = SQLiteDBBulkLoader(sqliteFileName=sqliteFile)


# truncate tables
Expand Down Expand Up @@ -79,7 +67,7 @@ def loadDBAfterTruncatingTables(self, sqliteFile, incrementLevel = 'increment_pa

# increment level 'increment_patch_release', 'increment_minor_release',
# or 'specified' (new version, perhaps major release)
loader.loadDBAfterTruncatingTables(sqliteFile = 'RaMP_SQLite_BASE.sqlite', incrementLevel = 'specified',
loader.loadDBAfterTruncatingTables(incrementLevel = 'specified',
optionalVersionOveride = "2.6.0",
optionalVersionNote = "20240524 data update",
truncateTables=True)
Expand Down
Binary file not shown.
5 changes: 1 addition & 4 deletions src/util/SQLiteDBBulkLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@
"""
class SQLiteDBBulkLoader(object):

def __init__(self, dbPropsFile, sqliteFileName):
def __init__(self, sqliteFileName):
print("rampDBBulkLoaer__init__")

# holds db credentials
# self.dbConf = dbConfig(dbPropsFile)

self.sqliteFileName = sqliteFileName

self.engine = self.createSQLiteEngine(sqliteFileName)
Expand Down

0 comments on commit b8b39d7

Please sign in to comment.