Database Utilities
Collection of functions that extend of simplify interactions with MySQL and SQLite databases
Import Module
using BioMedQuery.DBUtils
Index
BioMedQuery.DBUtils.assemble_cols_and_vals
BioMedQuery.DBUtils.assemble_cols_and_vals_select
BioMedQuery.DBUtils.assemble_vals
BioMedQuery.DBUtils.colname_dict
BioMedQuery.DBUtils.db_query
BioMedQuery.DBUtils.db_query
BioMedQuery.DBUtils.db_select
BioMedQuery.DBUtils.init_mysql_database
BioMedQuery.DBUtils.insert_row!
BioMedQuery.DBUtils.insert_row!
BioMedQuery.DBUtils.select_all_tables
BioMedQuery.DBUtils.select_all_tables
BioMedQuery.DBUtils.select_columns
BioMedQuery.DBUtils.select_columns
Functions
#
BioMedQuery.DBUtils.assemble_vals
— Method.
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.
#
BioMedQuery.DBUtils.db_query
— Method.
query_mysql(con, query_code)
Execute a mysql command
#
BioMedQuery.DBUtils.db_query
— Method.
query(db, query_code)
Execute a SQLite command
#
BioMedQuery.DBUtils.db_select
— Method.
select_(con, colnames, tablename, data_values)
Perform: SELECT colnames tablename WHERE keys(data_values)=values(data_values)
#
BioMedQuery.DBUtils.init_mysql_database
— Method.
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 tablesoverwrite::Bool
: Flag, if true and dbname exists, it deletes it
Output
con
: Database connection and table-column names map
#
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) valuesverbose
: Print debugginh info
#
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) valuesverbose
: Print debugginh info
#
BioMedQuery.DBUtils.assemble_cols_and_vals
— Method.
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.
#
BioMedQuery.DBUtils.assemble_cols_and_vals_select
— Function.
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.
#
BioMedQuery.DBUtils.colname_dict
— Method.
colname_dict_(con)
Return a dictionary maping tables and their columns for a given MySQL-connection/SQLite-database
#
BioMedQuery.DBUtils.select_all_tables
— Method.
select_all_tables_mysql(con)
Return an array of all tables in a given MySQL database
#
BioMedQuery.DBUtils.select_all_tables
— Method.
select_all_tables_mysql(con)
Return an array of all tables in a given MySQL database
#
BioMedQuery.DBUtils.select_columns
— Method.
select_columns_mysql(con, table)
For a MySQL database, return an array of all columns in the given table
#
BioMedQuery.DBUtils.select_columns
— Method.
select_columns(db, table)
Return an array with names of columns in the given table