E2E tests are using pyodbc and pytest.
The default DSN the tests use is ClickHouse DSN (ANSI)
. If required, the test DSN can be changed via the DSN
env variable.
- Build the driver from sources.
- Create the required INI files. You could also have a look how the config files are generated by the CI workflows.
Sample ~/.odbc.ini
config (can be used as is):
[ODBC Data Sources]
ClickHouse DSN (ANSI) = ClickHouse ODBC Driver (ANSI)
ClickHouse DSN (Unicode) = ClickHouse ODBC Driver (Unicode)
[ClickHouse DSN (ANSI)]
Driver = ClickHouse ODBC Driver (ANSI)
Description = DSN (localhost) for ClickHouse ODBC Driver (ANSI)
Url = http://localhost:8123
[ClickHouse DSN (Unicode)]
Driver = ClickHouse ODBC Driver (Unicode)
Description = DSN (localhost) for ClickHouse ODBC Driver (Unicode)
Url = http://localhost:8123
Sample ~/.odbcinst.ini
config (don't forget to replace /absolute/path/to/clickhouse-odbc
):
[ODBC Drivers]
ClickHouse ODBC Driver (ANSI) = Installed
ClickHouse ODBC Driver (Unicode) = Installed
[ClickHouse ODBC Driver (ANSI)]
Description = ODBC Driver (ANSI) for ClickHouse
Driver = /absolute/path/to/clickhouse-odbc/build/driver/libclickhouseodbc.so
Setup = /absolute/path/to/clickhouse-odbc/build/driver/libclickhouseodbc.so
UsageCount = 1
[ClickHouse ODBC Driver (Unicode)]
Description = ODBC Driver (Unicode) for ClickHouse
Driver = /absolute/path/to/clickhouse-odbc/build/driver/libclickhouseodbcw.so
Setup = /absolute/path/to/clickhouse-odbc/build/driver/libclickhouseodbcw.so
UsageCount = 1
Instead of placing the config files to the default locations (~/.odbc.ini
and ~/.odbcinst.ini
), you can create them elsewhere.
However, in this case, for the tests to run properly (this is the case for both Python e2e and C++ integration tests), the required environment variables should be set pointing the correct paths to the configuration files:
export ODBCSYSINI=
export ODBCINSTINI="/absolute/path/to/.odbcinst.ini"
export ODBCINI="/absolute/path/to/.odbc.ini"
IMPORTANT: note that the ODBCSYSINI
variable is overridden as an empty string.
Please refer to the CI workflows for more examples of such usage.
Having a virtual environment set up for the project (recommended), install the dependencies:
cd tests
pip install -r requirements.txt
Start the ClickHouse server in Docker, if it is not running locally already:
docker-compose up -d
Run the tests:
pytest
If the debug logs (queries, parameters etc) are required, you can run it as follows:
pytest --log-level=DEBUG -v
Verified with PyCharm 2024.1 and Python 3.12.
- Open the
test
directory in PyCharm as a new project - Create a new
venv
interpreter using PyCharm - Install all dependencies from the
requirements.txt
file
Now, you should be able to run the tests from the PyCharm itself.