File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 38
38
print (df )
39
39
print (df .describe ())
40
40
41
+ # Also you can use proton settings in DataFrame API like using `execute` function. # noqa
42
+ # Here's an example with idempotent id.
43
+
44
+ # Reset stream
45
+ c .execute ('drop stream if exists test' )
46
+ c .execute (
47
+ """create stream test (
48
+ year int16,
49
+ first_name string
50
+ )"""
51
+ )
52
+ settings = dict (use_numpy = True , idempotent_id = 'batch' )
53
+
54
+ # Execute multiple insert operations.
55
+ for _ in range (5 ):
56
+ c .insert_dataframe (
57
+ 'INSERT INTO "test" (year, first_name) VALUES' ,
58
+ df ,
59
+ settings = settings ,
60
+ )
61
+ time .sleep (3 )
62
+
63
+ rv = c .execute ('SELECT COUNT(*) FROM table(test)' )
64
+ # Only the first times insert into the historical storage.
65
+ print (rv ) # (4,)
66
+
41
67
# Converting query results to a variety of formats with dbapi
42
68
with connect ('proton://localhost' ) as conn :
43
69
with conn .cursor () as cur :
You can’t perform that action at this time.
0 commit comments