Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ESAP DB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ASTRON SDC
ESCAPE WP5
ESAP DB
Merge requests
!24
Resolve "API to delete table"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "API to delete table"
6-api-to-delete-table
into
master
Overview
0
Commits
1
Pipelines
2
Changes
8
Merged
Pierre Chanial
requested to merge
6-api-to-delete-table
into
master
3 years ago
Overview
0
Commits
1
Pipelines
2
Changes
8
Expand
Closes
#6 (closed)
Edited
3 years ago
by
Pierre Chanial
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
80b51a9b
1 commit,
3 years ago
8 files
+
255
−
166
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
8
Search (e.g. *.vue) (Ctrl+P)
app/apis/v0/tables.py
+
20
−
2
Options
@@ -4,7 +4,7 @@ import os
from
typing
import
Literal
import
requests
from
fastapi
import
APIRouter
,
Depends
,
HTTPException
,
status
from
fastapi
import
APIRouter
,
Depends
,
HTTPException
,
Response
,
status
from
pandas
import
DataFrame
from
sqlalchemy
import
text
from
sqlalchemy.engine
import
Connection
@@ -14,7 +14,7 @@ from sqlalchemy.orm import Session
from
...
import
db
from
...db.dbadmin
import
begin_session
from
...db.dbprojects
import
project_engines
from
...db.dbprojects.operations
import
select_table_column_names
from
...db.dbprojects.operations
import
drop_table
,
select_table_column_names
from
...schemas
import
(
BodyCreateTableFromESAPGatewayQuery
,
BodyCreateTableFromMapping
,
@@ -197,3 +197,21 @@ def get_table_column_names(
)
->
list
[
str
]:
"""
Returns the column names of a table.
"""
return
select_table_column_names
(
connection
,
dataset
,
table
)
@router.delete
(
'
/projects/{project}/datasets/{dataset}/tables/{table}
'
,
summary
=
'
Deletes a table.
'
)
def
delete_table
(
project
:
str
,
dataset
:
str
,
table
:
str
,
*
,
session
:
Session
=
Depends
(
get_session
),
connection
:
Connection
=
Depends
(
get_connection
),
)
->
Response
:
"""
Deletes a table.
"""
table_name
=
f
'
{
project
}
.
{
dataset
}
.
{
table
}
'
db
.
table
.
delete_by_name
(
session
,
table_name
)
drop_table
(
connection
,
table_name
)
return
Response
(
status_code
=
status
.
HTTP_204_NO_CONTENT
)
Loading