Database Utilities

Collection of functions that extend of simplify interactions with MySQL and SQLite databases

Import Module

using BioMedQuery.DBUtils

Index

Functions

# BioMedQuery.DBUtils.assemble_valsMethod.

assemble_vals(data_values, column_names)

Given a Dict of values and the column names, return a single string properly formatted for a MySQL INSERT. E.g MySQL requires CHAR or other non-numeric values be passed with single quotes around them.

source

# BioMedQuery.DBUtils.db_queryMethod.

query_mysql(con, query_code)

Execute a mysql command

source

# BioMedQuery.DBUtils.db_queryMethod.

query(db, query_code)

Execute a SQLite command

source

# BioMedQuery.DBUtils.db_selectMethod.

select_(con, colnames, tablename, data_values)

Perform: SELECT colnames tablename WHERE keys(data_values)=values(data_values)

source

# BioMedQuery.DBUtils.init_mysql_databaseMethod.

init_mysql_database(;host = "localhost", dbname="test",
username="root", pswd="", mysql_code=nothing, overwrite=false)

Create a MySQL database using the code inside mysql_code

Arguments

  • host, dbname, user, pswd
  • mysql_code::String: String with MySQL code that crates all default tables
  • overwrite::Bool : Flag, if true and dbname exists, it deletes it

Output

  • con: Database connection and table-column names map

source

# BioMedQuery.DBUtils.insert_row!Function.

insert_row!(db, tablename, values)

Insert a row of values into the specified table for a given a MySQL database handle

Arguments:

  • db::MySQLDB: Database object (connection and map)
  • data_values::Dict{String, Any}: Array of (string) values
  • verbose: Print debugginh info

source

# BioMedQuery.DBUtils.insert_row!Function.

insert_row!(db, tablename, values)

Insert a row of values into the specified table for a given a SQLite database handle

Arguments:

  • db::MySQLDB: Database object (connection and map)
  • data_values::Dict{String, Any}: Array of (string) values
  • verbose: Print debugginh info

source

# BioMedQuery.DBUtils.assemble_cols_and_valsMethod.

assemble_vals(data_values)

Given a dictionary containg (:column=>value) return a single string properly formatted for a MySQL insert. E.g MySQL requires CHAR or other non-numeric values be passed with single quotes around them.

source

# BioMedQuery.DBUtils.assemble_cols_and_vals_selectFunction.

assemble_vals(data_values)

Given a dictionary containg (:column=>value), return a single string properly formatted for a MySQL SELECT. E.g MySQL requires CHAR or other non-numeric values be passed with single quotes around them.

source

# BioMedQuery.DBUtils.colname_dictMethod.

colname_dict_(con)

Return a dictionary maping tables and their columns for a given MySQL-connection/SQLite-database

source

# BioMedQuery.DBUtils.select_all_tablesMethod.

select_all_tables_mysql(con)

Return an array of all tables in a given MySQL database

source

# BioMedQuery.DBUtils.select_all_tablesMethod.

select_all_tables_mysql(con)

Return an array of all tables in a given MySQL database

source

# BioMedQuery.DBUtils.select_columnsMethod.

select_columns_mysql(con, table)

For a MySQL database, return an array of all columns in the given table

source

# BioMedQuery.DBUtils.select_columnsMethod.

select_columns(db, table)

Return an array with names of columns in the given table

source