API Reference for Jorm.jl
Jorm.RawSQLJorm.backup_postgresql_dbJorm.backup_sqlite_dbJorm.connectJorm.connectJorm.create_tableJorm.delete!Jorm.delete_all!Jorm.delete_dbJorm.delete_dbJorm.disconnectJorm.disconnectJorm.drop_all_tablesJorm.execute_queryJorm.execute_queryJorm.filter_byJorm.filter_by_sqlJorm.getfirstJorm.groupby_sqlJorm.insert!Jorm.list_tablesJorm.ls_tablesJorm.read_allJorm.read_oneJorm.serialize_to_listJorm.tablenameJorm.update!Jorm.@raw_sql
Jorm.RawSQL — Typestruct RawSQL
value: StringA struct to hold raw SQL Queries
Jorm.backup_postgresql_db — Functionbackup_postgresql_db(db_name::String, host::String="localhost", user::String="postgres", password::String="", backup_file::String="backup.sql")
# Usage
backup_postgresql_db("mydb", "localhost", "postgres", "mypassword", "backup.sql")Jorm.backup_sqlite_db — Methodbackup_sqlite_db(db::SQLite.DB, model)
# usage
backup_sqlite_db("example.db", "example_backup.db")Jorm.connect — Methodconnect(connection_string::String)
-> LibPQ.ConnectionEstablish a connection to an SQLite database using the provided connection string.
Jorm.connect — Methodconnect(connection_string::String)
-> SQLite.DBEstablish a connection to an SQLite database using the provided connection string.
Jorm.create_table — Methodcreate_table(db::SQLite.DB, model, tableName)
Creates a table in the database based on the model.Jorm.delete! — Methoddelete!(db::SQLite.DB, model, id)
Delete data for a given modelJorm.delete_all! — Methoddelete_all(db::SQLite.DB, model)
Deletes all data in the table for the given modelJorm.delete_db — Methoddelete_db(connection_string::Jorm.PostgreSQLConnectionString)
Deletes or removes a an PostgreSQL databaseJorm.delete_db — Methoddelete_db(connection_string::Jorm.SQLiteConnectionString)
Deletes or removes a an sqlite databaseJorm.disconnect — Methoddisconnect(db::LibPQ.Connection)
-> NothingClose the connection to the PostgreSQL database.
Jorm.disconnect — Methoddisconnect(db::SQLite.DB)
-> NothingClose the connection to the SQLite database.
Jorm.drop_all_tables — Methoddrop_all_tables(connection_string::SQLiteConnectionString)
Delete or Drop all tables for a given tableJorm.execute_query — Functionexecute_query(db::SQLite.DB, query::RawSQL, params::Vector{Any}=Any[])
Returns the executed sqlJorm.execute_query — Functionexecute_query(db::LibPQ.Connection, query::RawSQL, params::Vector{Any}=Any[])
Returns the executed sqlJorm.filter_by — Methodfilter_by(db::SQLite.DB, model, table_name; kwargs...)
Returns the result of the given condition from the Database. This uses `SELECT`Jorm.filter_by_sql — Methodfilter_by_sql(table_name; kwargs...)
Filter data by condition from the databaseJorm.getfirst — Methodgetfirst(db::SQLite.DB, model, column,value)
Returns a given model object when given the column and the search valueJorm.groupby_sql — Methodgroupby_sql(table_name; group_by_columns, select_columns = "*", having_conditions = nothing, order_by_columns = nothing)
Returns the result of the given condition from the Database. This uses `SELECT`Jorm.insert! — Methodinsert!(db::SQLite.DB, model::Type, data)
Insert or Add data to the DB for a given modelJorm.list_tables — Methodlist_tables(connection_string::SQLiteConnectionString)
Returns the list of tables in DBJorm.ls_tables — Methodls_tables(connection_string::SQLiteConnectionString)
Returns the list of tables in DBJorm.read_all — Methodread_all(db::SQLite.DB, model)
Returns all data of a given model objectJorm.read_one — Methodread_one(db::SQLite.DB, model, id)
Returns a given model object when given the IDJorm.serialize_to_list — Methodserialize_to_list(outputmodel::Type,queryresult)
Convert an SQL Query result into serialized list
outputmodel:: Same Model but with id::Int defined to handle auto generated ID
from autoincrementJorm.tablename — Methodtablename(model)
Generate the table name for a given model. The table name is derived from the model's type name, converting it to lowercase and joining words with underscores.struct MyModel end println(tablename(MyModel)) # Output: "my_model"
Jorm.update! — Methodupdate!(db::SQLite.DB, model, id, data)
Update data to the DB for a given modelJorm.@raw_sql — Macromacro raw_sql(v::String)
-> RawSQLCreate a RawSQL instance from a given SQL query string.