Connecting to a database in Python
Import AlphaDB and the preferred engine. In this example we'll use MySQL.
use alphadb::AlphaDB;
use alphadb::engine::MySQLEngine;Initialize an instance and connect it to a database using MySQL credentials.
let engine = MySQLEngine::with_credentials("host", "user", "password", "database", 3306);
let mut db = AlphaDB::with_engine(engine);
let mut db = AlphaDB::new();
match db.connect() {
Ok(c) => println!("Connected!"),
Err(e) => eprintln!("Connection attempt failed")
}Replace the credentials with your own. AlphaDB requires the user to have the following privileges: CREATE, INSERT, DELETE, SELECT, UPDATE, ALTER, DROP and REFERENCES.