-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: include sqlalchemy 1.4 test in client testing
- Loading branch information
1 parent
50d1114
commit 89bbd28
Showing
8 changed files
with
139 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
39 changes: 17 additions & 22 deletions
39
integration_tests/client-library/python/materializeview.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,41 @@ | ||
import psycopg2 | ||
from client import client | ||
from crud import crud | ||
from client import Client | ||
from crud import SampleTableCrud | ||
|
||
|
||
# Represents the materialized view `average_salary_view_py`. | ||
class MaterializeView: | ||
def __init__(self, host, port, database, user, password): | ||
self.host = host | ||
self.database = database | ||
self.user = user | ||
self.password = password | ||
self.connection = None | ||
self.port=port | ||
self.client = Client(host, port, database, user, password) | ||
self.crud = SampleTableCrud(host, port, database, user, password) | ||
|
||
def create_mv(self): | ||
crud_ins = crud(self.host, self.port, self.database, self.user, self.password) | ||
crud_ins.create_table() | ||
crud_ins.insert_data("John",25,10000) | ||
crud_ins.insert_data("Shaun",25,11000) | ||
crud_ins.insert_data("Caul",25,14000) | ||
crud_ins.insert_data("Mantis",28,18000) | ||
crud_ins.insert_data("Tony",28,19000) | ||
mv_query=""" | ||
self.crud.create_table() | ||
self.crud.insert_data("John", 25, 10000) | ||
self.crud.insert_data("Shaun", 25, 11000) | ||
self.crud.insert_data("Caul", 25, 14000) | ||
self.crud.insert_data("Mantis", 28, 18000) | ||
self.crud.insert_data("Tony", 28, 19000) | ||
mv_query = """ | ||
CREATE MATERIALIZED VIEW average_salary_view_py AS | ||
SELECT age, AVG(salary) AS average_salary | ||
FROM sample_table_py | ||
GROUP BY age; | ||
""" | ||
try: | ||
databaseconnection = client(self.host, self.port,self.database, self.user, self.password) | ||
cursor=databaseconnection.connect() | ||
cursor = self.client.connect() | ||
cursor.execute(mv_query) | ||
databaseconnection.connection.commit() | ||
self.client.connection.commit() | ||
print("MV created successfully.") | ||
except psycopg2.Error as e: | ||
print("MV creation failed: ", str(e)) | ||
|
||
def drop_mv(self): | ||
mv_drop_query = "DROP materialized view average_salary_view_py;" | ||
try: | ||
databaseconnection = client(self.host, self.port,self.database, self.user, self.password) | ||
cursor=databaseconnection.connect() | ||
cursor = self.client.connect() | ||
cursor.execute(mv_drop_query) | ||
databaseconnection.connection.commit() | ||
self.client.connection.commit() | ||
print("MV dropped successfully.") | ||
except psycopg2.Error as e: | ||
print("MV drop failed: ", str(e)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
psycopg2-binary | ||
pytest | ||
pytest | ||
sqlalchemy-risingwave | ||
SQLAlchemy==1.4.51 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.