Skip to content

Commit

Permalink
New Sql (#198)
Browse files Browse the repository at this point in the history
* Added Actions to push image to quay.io

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Search OLM

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Removed Search OLM

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Update workflow

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Modified tca-release.yaml and add signature

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Add table to db

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Added class

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Removed class approach

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Add move2kube as a new catalg

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Added move2kube json file names

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Create custom table and save to csv

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Added new table: move2kube_images

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Create move2kube KG

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* move2kube standardized data

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Latest Verified publishers list

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* fixed incorrect file name

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Improved move2kube method

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* latest sql file

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* fixed path

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* new images

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* new search results

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Changed move2kube to ibmcloud

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Changed db version

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Changed db version, changed name to ibmcloudimage

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Added new catalog option: ibmcloud

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Added new db:1.0.5

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Removed import, Added logging

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Changed method name, changed move2kube to ibm_cloud

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Deleted files

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Deleted files

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Changed table name

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Changed version number

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Deleted add_tables.py

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Changed version to 1.0.5

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Script to add a custom table header to db

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* changed import

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* latest 1.0.4.sql

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

* Removed move2kube

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>

---------

Signed-off-by: lamwassi <lambert.pouguem.wassi@ibm.com>
  • Loading branch information
lamwassi authored Feb 10, 2023
1 parent 1c69dbe commit 37a6b61
Show file tree
Hide file tree
Showing 15 changed files with 25,317 additions and 10,410 deletions.
2 changes: 1 addition & 1 deletion config/common.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[general]
; KG version to use
version = 1.0.4
version = 1.0.5
; Directory containing train and inference data
data_dir = data
; Directory containing model files
Expand Down
5 changes: 4 additions & 1 deletion config/kg.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ baseOSKG = baseOSKG.json
dockerimageKG = dockerimageKG.json
openshiftimageKG = openshiftimageKG.json
openshiftbaseOSKG = openshiftbaseOSKG.json
ibmcloudimageKG = ibmcloudimageKG.json
operatorimageKG = operatorimageKG.json
inverted_baseOSKG = inverted_baseOSKG.json
inverted_dockerimageKG = inverted_dockerimageKG.json
inverted_openshiftimageKG = inverted_openshiftimageKG.json
inverted_openshiftbaseOSKG = inverted_openshiftbaseOSKG.json
inverted_operatorimageKG = inverted_operatorimageKG.json
inverted_compatibilityKG = inverted_compatibilityKG.json
inverted_ibmcloudimageKG = inverted_ibmcloudimageKG.json
compatibilityKG = compatibilityKG.json
compatibilityOSKG = compatibilityOSKG.json


[database]
database_path = db/1.0.4.db
database_path = db/1.0.5.db

[quay]
max_pages = 2
Expand Down
13,940 changes: 13,940 additions & 0 deletions db/1.0.5.sql

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions kg_utils/add_custom_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@

import sqlite3
import argparse
import configparser
import os
import logging

#config file
config = configparser.ConfigParser()
config_data = os.path.join("config/kg.ini")
config.read([config_data])
db_file = config["database"]["database_path"]


def table_names(conn) ->list:
"""
View table names.
Args:
conn (_type_): Connection to the database.
Returns:
list: A list containing all table names.
"""
cursor = conn.cursor()
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = []

for col in cursor.fetchall():
tables.append(col[0])
return tables



def create_table(conn, table_name:str, columns:str):

"""
Create a custom table.
Args:
conn (_type_): Connection to the database.
"""
cur = conn.cursor()
tab ="CREATE TABLE ibm-cloud-images (id integer PRIMARY KEY AUTOINCREMENT, container_name text NOT NULL, OS integer NOT NULL, lang integer, lib integer, app integer, app_server integer, plugin integer, runlib integer, runtime integer, ibm_cloud_correspondent_image_url text, FOREIGN KEY (OS) REFERENCES entities (id), FOREIGN KEY (lang) REFERENCES entities (id), FOREIGN KEY (lib) REFERENCES entities (id), FOREIGN KEY (app) REFERENCES entities (id), FOREIGN KEY (app_server) REFERENCES entities (id), FOREIGN KEY (plugin) REFERENCES entities (id), FOREIGN KEY (runlib) REFERENCES entities (id), FOREIGN KEY (runtime) REFERENCES entities (id))"
table = "CREATE TABLE {}{}".format(table_name, columns)
print(table)
cur.execute(tab)
logging.info("{} added to the database!".format(table_name))


def table_cmd()->object:
"""
Parses input arguments
Returns:
object: A parser
"""

parser = argparse.ArgumentParser(
prog = 'add_tables.py',
description = 'Add a new table to the database')
parser.add_argument('-t', '--table_name', required=True , help="Table's name")
parser.add_argument('-n', '--num_columns', required= True , help="Number of columns")
parser.add_argument('-f', '--num_foreign_keys', required=True , help="Number of foreign keys, if any.")
return parser.parse_args()



if "__name__==__main__":

# initiate connection to db file
conn = sqlite3.connect(db_file)
entries = table_cmd()

print("Existing table names")
print("==============================================================")
print(table_names(conn))

Ans = input("Would you like to drop any table? y/n: ")

if Ans.lower() == "y":
tab_name = input("Enter table name to drop")
conn.execute("DROP TABLE {}".format(tab_name))

print("Start adding a new table.")
columns = '('
print("Enter column name followed by data type along with any additional column constraints(PRIMARY KEY, NOT NULL, AUTOINCREMENT, DEFAULT, DETAILS, ETC ...)")
print("For common mysql data types, please refer to the documentation at: https://dev.mysql.com/doc/refman/8.0/en/data-types.html")
print("============================================================================================================================")

for num in list(range(int(entries.num_columns))):
col_ = input("column {}: ".format(num))
if num +1 == int(entries.num_columns) : columns += col_
else: columns += col_ + ', '

print("\n")
if entries.num_foreign_keys == 0: columns += ')'
else:
print("Enter any FOREIGN KEYS.")
print("Format: FOREIGN KEY (column_name) REFERENCES <table_name> (<corresponding column from table_name>)")
print("Example: FOREIGN KEY (entity_id) REFERENCES entities (id)")
print("==============================================================================================")
for num in list(range(int(entries.num_foreign_keys))):
f_key = input("FOREIGN KEY {} : ".format(num+1))
columns += ', ' + f_key

columns += ')'
create_table(conn,entries.table_name,columns)










Loading

0 comments on commit 37a6b61

Please sign in to comment.