Database-Related SDKs
Creating a Database
DLI provides an API for creating a database. You can use it to create a database. The sample code is as follows:
1 2 3 4 5 6 7 8 | def create_db(dli_client):
try:
db = dli_client.create_database('db_for_test')
except DliException as e:
print(e)
return
print(db)
|
The default database is a built-in database. You are not allowed to create a database named default.
Deleting a Database
DLI provides an API for deleting a database. The example code is as follows:
1 2 3 4 5 6 | def delete_db(dli_client, db_name):
try:
dli_client.delete_database(db_name)
except DliException as e:
print(e)
return
|
- A database that contains tables cannot be deleted. To delete a database that contains tables, delete the tables first.
- A deleted database cannot be restored. Therefore, exercise caution when deleting a database.
Last Article: SDKs Related to SQL Jobs
Next Article: Table-Related SDKs
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.