Overview¶
In order to build a visitor manually, or to use the generator journey functions we need to understand the classes needed.
Each class can create_
a child piece of data. For example Visitor can create_visit
but it can not create_page
. Where as a Visit can create_page
and create_event
.
All create_
functions return what they create allowing easy Visit building. For example:
new_visitor = Visitor()
# visitor. visit. page. event
new_visitor.create_visit().create_page().create_event()
new_visitor = Visitor()
# visitor. visit. page. visit. page
new_visitor.create_visit().create_page().visit.create_page()
new_visitor.create_visit()
new_visitor.create_visit()
new_visitor.create_visit()
new_visitor.visits[1].create_page()
new_visitor.visits[2].create_page()
new_visitor.visits[2].create_page()
new_visitor.visits[2].pages[1].create_event()
All classes have an insert
function that can be called when you're ready to insert that Visitor.
How To Use¶
Build your visitor, then simply call insert() at any stage. You must pass a connection
to insert(). If you need another wrapper you can implement your own CubedConnection
The Visit Generator comes with a pre built connection class wrapper for PyMySQLdb.
Example:
from visit_generator import connections
conn = connections.CubedConnectionMysqlDB(host=host, user=suer, password=password, db=db)
v = Visitor()
v.insert(conn)
v2 = Visitor()
v2.create_visit().create_page().insert(conn)
v3 = Visitor()
v3.create_visit().insert(conn)