from pyregatta import connect
host = "aaa.bbb.ccc.ddd:ppp"
user = "MyUserName"
password = "SomeSophisticatedPassword"
# The connection is automatically closed when the block is exited
with connect(user, password, host) as conn:
# Now you can perform database operations using the cursor
with conn.cursor() as cursor:
# Create table
cursor.execute("""CREATE TABLE employees (
employee_key INT PRIMARY KEY INDEX WITH (devices = (m10d1)),
employee_name VARCHAR(40) NOT NULL,
employee_salary INT,
employee_department VARCHAR(50) NOT NULL
) WITH (devices = (m10d1)) """)
# Insert values
cursor.execute("""INSERT INTO employees (
employee_key,
employee_name,
employee_salary,
employee_department)
VALUES
(1,'John Doe', 10932, 'DevOps'),
(2,'Richard Roe', 18324, 'Legal'),
(3,'Jane Roe', 20411, 'SoftwareDev'),
(4,'Rachel Roe', 19555, 'Support') """)
# Select all
cursor.execute("SELECT * FROM employees")
rows = cursor.fetchall()
# Print the results
for row in rows:
# Print the entire row
print(row)
"""
You can use this syntax to print a specific column:
print(row.id)
"""