File tree 2 files changed +13
-13
lines changed 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 21
21
data = b'{"Id":"1", "importantData":"some value"}' # Specify the event data body as a JSON in byte format
22
22
)
23
23
24
- ########################################################
24
+ ##################################################
25
25
#
26
- # Step 3. Append the event object into the SampleStream
26
+ # Step 3. Append the event object into the stream
27
27
#
28
- ########################################################
28
+ ##################################################
29
29
30
30
event_stream = "SampleStream" # Define the stream name where the event will be appended
31
- client .append_to_stream ( # Append the event to the SampleStream
31
+ client .append_to_stream ( # Append the event to a stream
32
32
event_stream , # Name of the stream to append the event to
33
33
events = [new_event ], # The event to append (in a list)
34
34
current_version = StreamState .ANY # Set to append regardless of the current stream state (you can ignore this for now)
Original file line number Diff line number Diff line change 9
9
# Create an instance of EventStoreDBClient, connecting to the EventStoreDB at localhost without TLS
10
10
client = EventStoreDBClient (uri = "esdb://localhost:2113?tls=false" )
11
11
12
- ################################################
12
+ ##########################################
13
13
#
14
- # Step 2. Read all events from the SampleStream
14
+ # Step 2. Read all events from the stream
15
15
#
16
- ################################################
16
+ ##########################################
17
17
18
18
events = client .get_stream ("SampleStream" ) # Read all events from SampleStream
19
19
23
23
#
24
24
######################################
25
25
26
- for event in events :
27
- print ("************************" );
28
- print ("You have read an event!" );
29
- print ("Stream: " + event .stream_name );
30
- print ("Event Type: " + event .type );
31
- print ("Event Body: " + event .data .decode ());
26
+ for event in events : # For each event
27
+ print ("************************" ); #
28
+ print ("You have read an event!" ); #
29
+ print ("Stream: " + event .stream_name ); # Print the stream name of the event
30
+ print ("Event Type: " + event .type ); # Print the type of the event
31
+ print ("Event Body: " + event .data .decode ()); # Print the body of the event after converting it to string from a byte array
32
32
print ("************************" );
33
33
34
34
client .close ()
You can’t perform that action at this time.
0 commit comments