Get started
Config Module
The Config class is used to configure the connection the database. It uses the SurrealHTTP and requires the following arguments:
url: URL of the databasenamespace: The namespace of the databasedatabase: The name of the databaseusername: The access usernamepassword: The access passwordclient: anSurrealHTTPclient configured beforehandfrom_env: if it set toTruethen it expects a.db_conffile where all the previous arguments are defined
Query Module
The Query module aims to replace the standard SurrealQL and make it more Python friendly. Internally it constructs a SurrealQL string from method chaining and sends the query to the database.
Initialize the query
Create examples
Create a new entry:
CREATE person CONTENT {
name: 'Tobie',
company: 'SurrealDB',
skills: ['Rust', 'Go', 'JavaScript']
};
becomes
table_name = "person"
cont = {
"name": "Tobie",
"company": "SurrealDB",
"skills": ["Rust", "Go", "JavaScript"],
}
create_query.create(table_name).content(cont)
Insert example
becomes
table_name = "person (name, company, founded)"
data = tuple(["John", "SurrealDB", "2021-09-10"])
insert_query.insert(table_name, values=data)
Select example
becomes
- Execution
To execute the query run res = await query.execute(), where res is the result of the query.