Skip to content

Commit

Permalink
Convert column names to snake_case in create_table function
Browse files Browse the repository at this point in the history
- Updated the create_table function to convert column names from camelCase to snake_case before creating the SQLite table.
- Included a new import for the camel_to_snake function to handle the conversion.
  • Loading branch information
OmarAI2003 committed Oct 25, 2024
1 parent e385460 commit 6f8fdab
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/scribe_data/load/data_to_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from tqdm.auto import tqdm

from scribe_data.cli.convert import camel_to_snake
from scribe_data.utils import (
DEFAULT_JSON_EXPORT_DIR,
DEFAULT_SQLITE_EXPORT_DIR,
Expand Down Expand Up @@ -108,11 +109,14 @@ def create_table(data_type, cols):
Parameters
----------
data_type : str
The name of the table to be created
The name of the table to be created.
cols : list of strings
The names of columns for the new table
The names of columns for the new table.
"""
# Convert column names to snake_case
cols = [camel_to_snake(col) for col in cols]

cursor.execute(
f"CREATE TABLE IF NOT EXISTS {data_type} ({' Text, '.join(cols)} Text, UNIQUE({cols[0]}))"
)
Expand Down

0 comments on commit 6f8fdab

Please sign in to comment.