What would creating a table called "price" in Synapse Analytics to hold the following columns, symbol, date, open, high, low, close, adj_close, and volume look like using Python and T-SQL?

1. Using Python:


# Example Python code for creating the "price" table
import pymssql

# Connect to Synapse SQL
connection = pymssql.connect(server="your_server_name", user="your_username", password="your_password")
cursor = connection.cursor()

# Define the SQL statement for table creation
create_table_sql = """
CREATE TABLE price (
  symbol VARCHAR(10) NOT NULL,
  date DATE NOT NULL,
  open DECIMAL(10, 2) NOT NULL,
  high DECIMAL(10, 2) NOT NULL,
  low DECIMAL(10, 2) NOT NULL,
  close DECIMAL(10, 2) NOT NULL,
  adj_close DECIMAL(10, 2) NOT NULL,
  volume BIGINT NOT NULL
);
"""

# Execute the SQL statement
cursor.execute(create_table_sql)

# Commit changes and close connection
connection.commit()
cursor.close()
connection.close()
                

2. Using T-SQL:


-- T-SQL code for creating the "price" table
CREATE TABLE price (
  symbol VARCHAR(10) NOT NULL,
  date DATE NOT NULL,
  open DECIMAL(10, 2) NOT NULL,
  high DECIMAL(10, 2) NOT NULL,
  low DECIMAL(10, 2) NOT NULL,
  close DECIMAL(10, 2) NOT NULL,
  adj_close DECIMAL(10, 2) NOT NULL,
  volume BIGINT NOT NULL
);
                

Both options achieve the same outcome of creating the "price" table with the specified columns. Choose the method that best suits your comfort level and workflow within Synapse Analytics.