@@ -56,26 +56,26 @@ def run_table_operations(project_id, instance_id, table_id):
56
56
57
57
# Check whether table exists in an instance.
58
58
# Create table if it does not exists.
59
- print 'Checking if table {} exists...' .format (table_id )
59
+ print ( 'Checking if table {} exists...' .format (table_id ) )
60
60
if table .exists ():
61
- print 'Table {} already exists.' .format (table_id )
61
+ print ( 'Table {} already exists.' .format (table_id ) )
62
62
else :
63
- print 'Creating the {} table.' .format (table_id )
63
+ print ( 'Creating the {} table.' .format (table_id ) )
64
64
table .create ()
65
- print 'Created table {}.' .format (table_id )
65
+ print ( 'Created table {}.' .format (table_id ) )
66
66
67
67
# [START bigtable_list_tables]
68
68
tables = instance .list_tables ()
69
- print 'Listing tables in current project...'
69
+ print ( 'Listing tables in current project...' )
70
70
if tables != []:
71
71
for tbl in tables :
72
- print tbl .table_id
72
+ print ( tbl .table_id )
73
73
else :
74
- print 'No table exists in current project...'
74
+ print ( 'No table exists in current project...' )
75
75
# [END bigtable_list_tables]
76
76
77
77
# [START bigtable_create_family_gc_max_age]
78
- print 'Creating column family cf1 with with MaxAge GC Rule...'
78
+ print ( 'Creating column family cf1 with with MaxAge GC Rule...' )
79
79
# Create a column family with GC policy : maximum age
80
80
# where age = current time minus cell timestamp
81
81
@@ -84,11 +84,11 @@ def run_table_operations(project_id, instance_id, table_id):
84
84
85
85
column_family1 = table .column_family ('cf1' , max_age_rule )
86
86
column_family1 .create ()
87
- print 'Created column family cf1 with MaxAge GC Rule.'
87
+ print ( 'Created column family cf1 with MaxAge GC Rule.' )
88
88
# [END bigtable_create_family_gc_max_age]
89
89
90
90
# [START bigtable_create_family_gc_max_versions]
91
- print 'Creating column family cf2 with max versions GC rule...'
91
+ print ( 'Creating column family cf2 with max versions GC rule...' )
92
92
# Create a column family with GC policy : most recent N versions
93
93
# where 1 = most recent version
94
94
@@ -97,11 +97,11 @@ def run_table_operations(project_id, instance_id, table_id):
97
97
98
98
column_family2 = table .column_family ('cf2' , max_versions_rule )
99
99
column_family2 .create ()
100
- print 'Created column family cf2 with Max Versions GC Rule.'
100
+ print ( 'Created column family cf2 with Max Versions GC Rule.' )
101
101
# [END bigtable_create_family_gc_max_versions]
102
102
103
103
# [START bigtable_create_family_gc_union]
104
- print 'Creating column family cf3 with union GC rule...'
104
+ print ( 'Creating column family cf3 with union GC rule...' )
105
105
# Create a column family with GC policy to drop data that matches
106
106
# at least one condition.
107
107
# Define a GC rule to drop cells older than 5 days or not the
@@ -112,11 +112,11 @@ def run_table_operations(project_id, instance_id, table_id):
112
112
113
113
column_family3 = table .column_family ('cf3' , union_rule )
114
114
column_family3 .create ()
115
- print 'Created column family cf3 with Union GC rule'
115
+ print ( 'Created column family cf3 with Union GC rule' )
116
116
# [END bigtable_create_family_gc_union]
117
117
118
118
# [START bigtable_create_family_gc_intersection]
119
- print 'Creating column family cf4 with Intersection GC rule...'
119
+ print ( 'Creating column family cf4 with Intersection GC rule...' )
120
120
# Create a column family with GC policy to drop data that matches
121
121
# all conditions
122
122
# GC rule: Drop cells older than 5 days AND older than the most
@@ -127,11 +127,11 @@ def run_table_operations(project_id, instance_id, table_id):
127
127
128
128
column_family4 = table .column_family ('cf4' , intersection_rule )
129
129
column_family4 .create ()
130
- print 'Created column family cf4 with Intersection GC rule.'
130
+ print ( 'Created column family cf4 with Intersection GC rule.' )
131
131
# [END bigtable_create_family_gc_intersection]
132
132
133
133
# [START bigtable_create_family_gc_nested]
134
- print 'Creating column family cf5 with a Nested GC rule...'
134
+ print ( 'Creating column family cf5 with a Nested GC rule...' )
135
135
# Create a column family with nested GC policies.
136
136
# Create a nested GC rule:
137
137
# Drop cells that are either older than the 10 recent versions
@@ -147,16 +147,16 @@ def run_table_operations(project_id, instance_id, table_id):
147
147
148
148
column_family5 = table .column_family ('cf5' , nested_rule )
149
149
column_family5 .create ()
150
- print 'Created column family cf5 with a Nested GC rule.'
150
+ print ( 'Created column family cf5 with a Nested GC rule.' )
151
151
# [END bigtable_create_family_gc_nested]
152
152
153
153
# [START bigtable_list_column_families]
154
- print 'Printing Column Family and GC Rule for all column families...'
154
+ print ( 'Printing Column Family and GC Rule for all column families...' )
155
155
column_families = table .list_column_families ()
156
156
for column_family_name , gc_rule in sorted (column_families .items ()):
157
- print 'Column Family:' , column_family_name
158
- print 'GC Rule:'
159
- print gc_rule .to_pb ()
157
+ print ( 'Column Family:' , column_family_name )
158
+ print ( 'GC Rule:' )
159
+ print ( gc_rule .to_pb () )
160
160
# Sample output:
161
161
# Column Family: cf4
162
162
# GC Rule:
@@ -174,33 +174,33 @@ def run_table_operations(project_id, instance_id, table_id):
174
174
# }
175
175
# [END bigtable_list_column_families]
176
176
177
- print 'Print column family cf1 GC rule before update...'
178
- print 'Column Family: cf1'
179
- print column_family1 .to_pb ()
177
+ print ( 'Print column family cf1 GC rule before update...' )
178
+ print ( 'Column Family: cf1' )
179
+ print ( column_family1 .to_pb () )
180
180
181
181
# [START bigtable_update_gc_rule]
182
- print 'Updating column family cf1 GC rule...'
182
+ print ( 'Updating column family cf1 GC rule...' )
183
183
# Update the column family cf1 to update the GC rule
184
184
column_family1 = table .column_family (
185
185
'cf1' ,
186
186
column_family .MaxVersionsGCRule (1 ))
187
187
column_family1 .update ()
188
- print 'Updated column family cf1 GC rule\n '
188
+ print ( 'Updated column family cf1 GC rule\n ' )
189
189
# [END bigtable_update_gc_rule]
190
190
191
- print 'Print column family cf1 GC rule after update...'
192
- print 'Column Family: cf1'
193
- print column_family1 .to_pb ()
191
+ print ( 'Print column family cf1 GC rule after update...' )
192
+ print ( 'Column Family: cf1' )
193
+ print ( column_family1 .to_pb () )
194
194
195
195
# [START bigtable_delete_family]
196
- print 'Delete a column family cf2...'
196
+ print ( 'Delete a column family cf2...' )
197
197
# Delete a column family
198
198
column_family2 .delete ()
199
- print 'Column family cf2 deleted successfully.'
199
+ print ( 'Column family cf2 deleted successfully.' )
200
200
# [END bigtable_delete_family]
201
201
202
- print 'execute command "python tableadmin.py delete [project_id] \
203
- [instance_id] --table [tableName]" to delete the table.'
202
+ print ( 'execute command "python tableadmin.py delete [project_id] \
203
+ [instance_id] --table [tableName]" to delete the table.')
204
204
205
205
206
206
def delete_table (project_id , instance_id , table_id ):
@@ -223,14 +223,14 @@ def delete_table(project_id, instance_id, table_id):
223
223
# [START bigtable_delete_table]
224
224
# Delete the entire table
225
225
226
- print 'Checking if table {} exists...' .format (table_id )
226
+ print ( 'Checking if table {} exists...' .format (table_id ) )
227
227
if table .exists ():
228
- print 'Table {} exists.' .format (table_id )
229
- print 'Deleting {} table.' .format (table_id )
228
+ print ( 'Table {} exists.' .format (table_id ) )
229
+ print ( 'Deleting {} table.' .format (table_id ) )
230
230
table .delete ()
231
- print 'Deleted {} table.' .format (table_id )
231
+ print ( 'Deleted {} table.' .format (table_id ) )
232
232
else :
233
- print 'Table {} does not exists.' .format (table_id )
233
+ print ( 'Table {} does not exists.' .format (table_id ) )
234
234
# [END bigtable_delete_table]
235
235
236
236
@@ -261,5 +261,5 @@ def delete_table(project_id, instance_id, table_id):
261
261
elif args .command .lower () == 'delete' :
262
262
delete_table (args .project_id , args .instance_id , args .table )
263
263
else :
264
- print 'Command should be either run or delete.\n Use argument -h,\
265
- --help to show help and exit.'
264
+ print ( 'Command should be either run or delete.\n Use argument -h,\
265
+ --help to show help and exit.')
0 commit comments