Skip to content

Commit

Permalink
fixup! db: Implement basic import/export of data
Browse files Browse the repository at this point in the history
sanitize table name
  • Loading branch information
victorlin committed Dec 31, 2022
1 parent 23a2c81 commit 30c7bcc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions augur/db/import_/sqlite3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from augur.errors import AugurError
from augur.io.metadata import Metadata
from augur.io.sequences import Sequences
from augur.io.sqlite3 import Sqlite3Database
from augur.io.sqlite3 import Sqlite3Database, sanitize_identifier


class Sqlite3ImportError(AugurError):
Expand Down Expand Up @@ -49,7 +49,7 @@ def import_metadata(metadata: Metadata, table_name: str, database: Sqlite3Databa
raise Sqlite3ImportError(f'Failed to create table: {e}')

insert_statement = f"""
INSERT INTO {table_name}
INSERT INTO {sanitize_identifier(table_name)}
VALUES ({','.join(['?' for _ in metadata.names])})
"""
rows = metadata.rows()
Expand All @@ -76,7 +76,7 @@ def import_sequences(sequences: Sequences, id_column: str, table_name: str, data
raise Sqlite3ImportError(f'Failed to create table: {e}')

insert_statement = f"""
INSERT INTO {table_name}
INSERT INTO {sanitize_identifier(table_name)}
VALUES ({','.join(['?' for _ in columns])})
"""
records = ((record.id, str(record.seq)) for record in sequences.get_seqrecords())
Expand Down

0 comments on commit 30c7bcc

Please sign in to comment.