28
28
from .statement import (FindStatement , AddStatement , RemoveStatement ,
29
29
ModifyStatement , SelectStatement , InsertStatement ,
30
30
DeleteStatement , UpdateStatement ,
31
- CreateCollectionIndexStatement , CreateViewStatement ,
32
- AlterViewStatement , CreateTableStatement )
31
+ CreateCollectionIndexStatement )
33
32
34
33
35
34
_COUNT_VIEWS_QUERY = ("SELECT COUNT(*) FROM information_schema.views "
40
39
"WHERE schema_name like '{0}'" )
41
40
_COUNT_QUERY = "SELECT COUNT(*) FROM `{0}`.`{1}`"
42
41
_DROP_TABLE_QUERY = "DROP TABLE IF EXISTS `{0}`.`{1}`"
43
- _DROP_VIEW_QUERY = "DROP VIEW IF EXISTS `{0}`.`{1}`"
44
42
45
43
46
44
class DatabaseObject (object ):
@@ -243,28 +241,6 @@ def drop_collection(self, name):
243
241
self ._connection .execute_nonquery (
244
242
"sql" , _DROP_TABLE_QUERY .format (self ._name , name ), False )
245
243
246
- def drop_table (self , name ):
247
- """Drops a table.
248
-
249
- Args:
250
- name (str): The name of the table to be dropped.
251
- """
252
- table = Table (self , name )
253
- if table .is_view ():
254
- self .drop_view (name )
255
- else :
256
- self ._connection .execute_nonquery (
257
- "sql" , _DROP_TABLE_QUERY .format (self ._name , name ), False )
258
-
259
- def drop_view (self , name ):
260
- """Drops a view.
261
-
262
- Args:
263
- name (str): The name of the view to be dropped.
264
- """
265
- self ._connection .execute_nonquery (
266
- "sql" , _DROP_VIEW_QUERY .format (self ._name , name ), False )
267
-
268
244
def create_collection (self , name , reuse = False ):
269
245
"""Creates in the current schema a new collection with the specified
270
246
name and retrieves an object representing the new collection created.
@@ -290,53 +266,6 @@ def create_collection(self, name, reuse=False):
290
266
raise ProgrammingError ("Collection already exists" )
291
267
return collection
292
268
293
- def create_view (self , name , replace = False ):
294
- """Creates in the current schema a new view with the specified name
295
- and retrieves an object representing the new view created.
296
-
297
- Args:
298
- name (string): The name of the view.
299
- replace (Optional[bool]): `True` to add replace.
300
-
301
- Returns:
302
- mysqlx.View: View object.
303
- """
304
- view = View (self , name )
305
- return view .get_create_statement (replace )
306
-
307
- def alter_view (self , name ):
308
- """Alters a view in the current schema with the specified name and
309
- retrieves an object representing the view.
310
-
311
- Args:
312
- name (string): The name of the view.
313
-
314
- Returns:
315
- mysqlx.View: View object.
316
- """
317
- view = View (self , name )
318
- return view .get_alter_statement ()
319
-
320
- def create_table (self , name , reuse = False ):
321
- """Creates in the current schema a table with the specified name and
322
- retrieves an object representing the new table created.
323
-
324
- Args:
325
- name (string): The name of the name.
326
- reuse (Optional[bool]): `True` to reuse.
327
-
328
- Returns:
329
- mysqlx.Table: Table object.
330
- """
331
- if not name :
332
- raise ProgrammingError ("Table name is invalid" )
333
- table = Table (self , name )
334
- if not table .exists_in_database ():
335
- return CreateTableStatement (self , name )
336
- elif not reuse :
337
- raise ProgrammingError ("Table already exists" )
338
- return table
339
-
340
269
341
270
class Collection (DatabaseObject ):
342
271
"""Represents a collection of documents on a schema.
@@ -577,22 +506,3 @@ def exists_in_database(self):
577
506
"""
578
507
sql = _COUNT_VIEWS_QUERY .format (self ._schema .name , self ._name )
579
508
return self ._connection .execute_sql_scalar (sql ) == 1
580
-
581
- def get_create_statement (self , replace = False ):
582
- """Creates a new :class:`mysqlx.CreateViewStatement` object.
583
-
584
- Args:
585
- replace (Optional[bool]): `True` to add replace.
586
-
587
- Returns:
588
- mysqlx.CreateViewStatement: CreateViewStatement object.
589
- """
590
- return CreateViewStatement (self , replace )
591
-
592
- def get_alter_statement (self ):
593
- """Creates a new :class:`mysqlx.AlterViewStatement` object.
594
-
595
- Returns:
596
- mysqlx.AlterViewStatement: AlterViewStatement object.
597
- """
598
- return AlterViewStatement (self )
0 commit comments