File tree 2 files changed +27
-5
lines changed
2 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -244,14 +244,14 @@ def get_schema(
244
244
return sch .Schema (fields )
245
245
246
246
def create_database (self , name : str , force : bool = False ) -> None :
247
- sql = sge .Create (kind = "DATABASE" , exist = force , this = sg . to_identifier ( name )). sql (
248
- self . name
249
- )
247
+ sql = sge .Create (
248
+ kind = "DATABASE" , exists = force , this = sg . to_identifier ( name )
249
+ ). sql ( self . name )
250
250
with self .begin () as cur :
251
251
cur .execute (sql )
252
252
253
253
def drop_database (self , name : str , force : bool = False ) -> None :
254
- sql = sge .Drop (kind = "DATABASE" , exist = force , this = sg .to_identifier (name )).sql (
254
+ sql = sge .Drop (kind = "DATABASE" , exists = force , this = sg .to_identifier (name )).sql (
255
255
self .name
256
256
)
257
257
with self .begin () as cur :
Original file line number Diff line number Diff line change 18
18
MYSQL_PASS ,
19
19
MYSQL_USER ,
20
20
)
21
- from ibis .backends .tests .errors import MySQLOperationalError
21
+ from ibis .backends .tests .errors import MySQLOperationalError , MySQLProgrammingError
22
22
from ibis .util import gen_name
23
23
24
24
MYSQL_TYPES = [
@@ -245,3 +245,25 @@ def test_invalid_port():
245
245
url = f"mysql://{ MYSQL_USER } :{ MYSQL_PASS } @{ MYSQL_HOST } :{ port } /{ IBIS_TEST_MYSQL_DB } "
246
246
with pytest .raises (MySQLOperationalError ):
247
247
ibis .connect (url )
248
+
249
+
250
+ def test_create_database_exists (con ):
251
+ con .create_database (dbname := gen_name ("dbname" ))
252
+
253
+ with pytest .raises (MySQLProgrammingError ):
254
+ con .create_database (dbname )
255
+
256
+ con .create_database (dbname , force = True )
257
+
258
+ con .drop_database (dbname , force = True )
259
+
260
+
261
+ def test_drop_database_exists (con ):
262
+ con .create_database (dbname := gen_name ("dbname" ))
263
+
264
+ con .drop_database (dbname )
265
+
266
+ with pytest .raises (MySQLOperationalError ):
267
+ con .drop_database (dbname )
268
+
269
+ con .drop_database (dbname , force = True )
You can’t perform that action at this time.
0 commit comments