@@ -339,7 +339,7 @@ def optimize(path, tables, no_vacuum, load_extension):
339339 tables = db .table_names (fts4 = True ) + db .table_names (fts5 = True )
340340 with db .conn :
341341 for table in tables :
342- db [ table ] .optimize ()
342+ db . table ( table ) .optimize ()
343343 if not no_vacuum :
344344 db .vacuum ()
345345
@@ -367,7 +367,7 @@ def rebuild_fts(path, tables, load_extension):
367367 tables = db .table_names (fts4 = True ) + db .table_names (fts5 = True )
368368 with db .conn :
369369 for table in tables :
370- db [ table ] .rebuild_fts ()
370+ db . table ( table ) .rebuild_fts ()
371371
372372
373373@cli .command ()
@@ -497,7 +497,7 @@ def add_column(
497497 _register_db_for_cleanup (db )
498498 _load_extensions (db , load_extension )
499499 try :
500- db [ table ] .add_column (
500+ db . table ( table ) .add_column (
501501 col_name , col_type , fk = fk , fk_col = fk_col , not_null_default = not_null_default
502502 )
503503 except OperationalError as ex :
@@ -535,7 +535,7 @@ def add_foreign_key(
535535 _register_db_for_cleanup (db )
536536 _load_extensions (db , load_extension )
537537 try :
538- db [ table ] .add_foreign_key (column , other_table , other_column , ignore = ignore )
538+ db . table ( table ) .add_foreign_key (column , other_table , other_column , ignore = ignore )
539539 except AlterError as e :
540540 raise click .ClickException (str (e ))
541541
@@ -645,7 +645,7 @@ def create_index(
645645 if col .startswith ("-" ):
646646 col = DescIndex (col [1 :])
647647 columns .append (col )
648- db [ table ] .create_index (
648+ db . table ( table ) .create_index (
649649 columns ,
650650 index_name = name ,
651651 unique = unique ,
@@ -729,7 +729,7 @@ def populate_fts(path, table, column, load_extension):
729729 db = sqlite_utils .Database (path )
730730 _register_db_for_cleanup (db )
731731 _load_extensions (db , load_extension )
732- db [ table ] .populate_fts (column )
732+ db . table ( table ) .populate_fts (column )
733733
734734
735735@cli .command (name = "disable-fts" )
@@ -751,7 +751,7 @@ def disable_fts(path, table, load_extension):
751751 db = sqlite_utils .Database (path )
752752 _register_db_for_cleanup (db )
753753 _load_extensions (db , load_extension )
754- db [ table ] .disable_fts ()
754+ db . table ( table ) .disable_fts ()
755755
756756
757757@cli .command (name = "enable-wal" )
@@ -827,7 +827,7 @@ def enable_counts(path, tables, load_extension):
827827 if bad_tables :
828828 raise click .ClickException ("Invalid tables: {}" .format (bad_tables ))
829829 for table in tables :
830- db [ table ] .enable_counts ()
830+ db . table ( table ) .enable_counts ()
831831
832832
833833@cli .command (name = "reset-counts" )
@@ -1147,7 +1147,7 @@ def insert_upsert_implementation(
11471147 return
11481148
11491149 try :
1150- db [ table ] .insert_all (
1150+ db . table ( table ) .insert_all (
11511151 docs , pk = pk , batch_size = batch_size , alter = alter , ** extra_kwargs
11521152 )
11531153 except Exception as e :
@@ -1174,7 +1174,7 @@ def insert_upsert_implementation(
11741174 else :
11751175 raise
11761176 if tracker is not None :
1177- db [ table ] .transform (types = tracker .types )
1177+ db . table ( table ) .transform (types = tracker .types )
11781178
11791179 # Clean up open file-like objects
11801180 if sniff_buffer :
@@ -1637,7 +1637,7 @@ def create_table(
16371637 table
16381638 )
16391639 )
1640- db [ table ] .create (
1640+ db . table ( table ) .create (
16411641 coltypes ,
16421642 pk = pks [0 ] if len (pks ) == 1 else pks ,
16431643 not_null = not_null ,
@@ -1668,7 +1668,7 @@ def duplicate(path, table, new_table, ignore, load_extension):
16681668 _register_db_for_cleanup (db )
16691669 _load_extensions (db , load_extension )
16701670 try :
1671- db [ table ] .duplicate (new_table )
1671+ db . table ( table ) .duplicate (new_table )
16721672 except NoTable :
16731673 if not ignore :
16741674 raise click .ClickException ('Table "{}" does not exist' .format (table ))
@@ -2029,9 +2029,9 @@ def memory(
20292029 if flatten :
20302030 rows = (_flatten (row ) for row in rows )
20312031
2032- db [ file_table ] .insert_all (rows , alter = True )
2032+ db . table ( file_table ) .insert_all (rows , alter = True )
20332033 if tracker is not None :
2034- db [ file_table ] .transform (types = tracker .types )
2034+ db . table ( file_table ) .transform (types = tracker .types )
20352035 # Add convenient t / t1 / t2 views
20362036 view_names = ["t{}" .format (i + 1 )]
20372037 if i == 0 :
@@ -2201,7 +2201,7 @@ def search(
22012201 _register_db_for_cleanup (db )
22022202 _load_extensions (db , load_extension )
22032203 # Check table exists
2204- table_obj = db [ dbtable ]
2204+ table_obj = db . table ( dbtable )
22052205 if not table_obj .exists ():
22062206 raise click .ClickException ("Table '{}' does not exist" .format (dbtable ))
22072207 if not table_obj .detect_fts ():
@@ -2613,10 +2613,10 @@ def transform(
26132613 kwargs ["add_foreign_keys" ] = add_foreign_keys
26142614
26152615 if sql :
2616- for line in db [ table ] .transform_sql (** kwargs ):
2616+ for line in db . table ( table ) .transform_sql (** kwargs ):
26172617 click .echo (line )
26182618 else :
2619- db [ table ] .transform (** kwargs )
2619+ db . table ( table ) .transform (** kwargs )
26202620
26212621
26222622@cli .command ()
@@ -2804,7 +2804,7 @@ def _content_text(p):
28042804 _load_extensions (db , load_extension )
28052805 try :
28062806 with db .conn :
2807- db [ table ] .insert_all (
2807+ db . table ( table ) .insert_all (
28082808 to_insert (),
28092809 pk = pks [0 ] if len (pks ) == 1 else pks ,
28102810 alter = alter ,
@@ -3123,7 +3123,7 @@ def wrapped_fn(value):
31233123
31243124 fn = wrapped_fn
31253125 try :
3126- db [ table ] .convert (
3126+ db . table ( table ) .convert (
31273127 columns ,
31283128 fn ,
31293129 where = where ,
@@ -3213,7 +3213,7 @@ def add_geometry_column(
32133213 _load_extensions (db , load_extension )
32143214 db .init_spatialite ()
32153215
3216- if db [ table ] .add_geometry_column (
3216+ if db . table ( table ) .add_geometry_column (
32173217 column_name , geometry_type , srid , coord_dimension , not_null
32183218 ):
32193219 click .echo (f"Added { geometry_type } column { column_name } to { table } " )
@@ -3251,7 +3251,7 @@ def create_spatial_index(db_path, table, column_name, load_extension):
32513251 "You must add a geometry column before creating a spatial index"
32523252 )
32533253
3254- db [ table ] .create_spatial_index (column_name )
3254+ db . table ( table ) .create_spatial_index (column_name )
32553255
32563256
32573257@cli .command (name = "plugins" )
0 commit comments