Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cb2c3f5
feat: add data insert script, modified decoder, dbconn and dbqry
Viishveesh May 3, 2025
4d298d2
Updated the aggregate table logic in dbconn.py
Viishveesh May 5, 2025
9fa9318
Update dbquery and drcoder.py files
Viishveesh May 8, 2025
5e05b39
update: make dbqury and sqlfcn compatible with global tables and adde…
Viishveesh May 8, 2025
41ccacc
Fix Decoder and add test case to test insertion
Viishveesh May 10, 2025
455cde8
Add test cases to test decoder, sqlfcn, postgres insertion, dbqry
Viishveesh May 15, 2025
008023c
Remove unused code and old commented code
Viishveesh May 15, 2025
290cb9f
Fix the environment variable name in test case
Viishveesh May 21, 2025
9eed084
Fix the test cases
Viishveesh May 21, 2025
29d638e
ignore old test_001_postgres.py file in CI
Viishveesh May 22, 2025
2901fba
Fixing the errors to pass test case
Viishveesh May 22, 2025
3616129
Change the timescaledb-postgres version to 17 in windows job
Viishveesh May 23, 2025
4c8610a
Change the pgRoot in ci pipeline
Viishveesh May 23, 2025
e76f2b2
Add pgsql bin to path
Viishveesh May 23, 2025
b4e275e
Trying to fix the windows timescaledb isntallation
Viishveesh May 23, 2025
e618611
Change the order to run installer before changing the config
Viishveesh May 23, 2025
95f7cc8
Update CI.yml file for fixing timescaledb issye on windows
Viishveesh May 24, 2025
3b2913c
Merge branch 'vishvesh/dev' of github.com:AISViz/AISdb into vishvesh/dev
Viishveesh May 24, 2025
0a56efd
Update CI.yml revoke shared preload lib for Windows timescaledb
tsuzzy May 26, 2025
0b1c590
Update CI.yml change pgdatadir
tsuzzy May 27, 2025
f8a7f21
Update CI.yml
tsuzzy May 27, 2025
1d583b6
Update CI.yml
tsuzzy May 27, 2025
58ef0b3
Removed sqlite support from python files
Viishveesh May 29, 2025
244f361
Remove the sqlite support from the test case
Viishveesh Jun 4, 2025
95bea30
Remove sqlite support and add postgresql support
Viishveesh Jun 5, 2025
906e596
feat: remove the sqlite table creation test case
Viishveesh Jun 5, 2025
fcecdd6
fix merge conflicts
Viishveesh Jun 6, 2025
b196c92
Merge branch 'master' into vishvesh/rm-sqlite
Viishveesh Jun 6, 2025
008bcc9
update decoder.py
Viishveesh Jun 13, 2025
39040e5
Update test cases to work with only postgresql
Viishveesh Jun 13, 2025
e5973dc
update tge test_005_dbqry.py
Viishveesh Jun 13, 2025
8b97015
remove test case for sqlite
Viishveesh Jun 17, 2025
de8864a
fix the failing test cases
Viishveesh Jun 18, 2025
8c7cd47
fix test case
Viishveesh Jun 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,13 @@ jobs:
maturin develop --release --extras=test,docs
python -m pip install --upgrade pytest pytest-dotenv pytest-cov furl hypothesis trustme astor pyopenssl isort pydirectory

- name: Create testdata directory
run: mkdir -p ./AISdb/testdata

- name: Run Tests
run: |
AISdb\Scripts\activate
pytest ./aisdb/tests/ --ignore=./aisdb/tests/test_014_marinetraffic.py --maxfail=10
pytest ./aisdb/tests/ --ignore=./aisdb/tests/test_014_marinetraffic.py --ignore=./aisdb/tests/test_001_postgres.py --maxfail=10

- name: Clean Up
run: |
Expand Down Expand Up @@ -186,6 +189,7 @@ jobs:
database: postgres
postgres-version: "17"
ssl: false
port: 5432
id: postgres

- name: Test PostgreSQL Connection
Expand All @@ -205,11 +209,6 @@ jobs:
run: |
sudo apt-get install -y timescaledb-2-postgresql-17 postgresql-client-17
echo "TimescaleDB Extension installed"

# - name: Apply TimescaleDB tuning
# run: |
# sudo timescaledb-tune --pg-config="/home/runner/work/_temp/pgdata/postgresql.conf" --quiet --yes
# echo "TimescaleDB tuning applied"

- name: Enable TimescaleDB in PostgreSQL Config
run: |
Expand Down Expand Up @@ -237,10 +236,13 @@ jobs:
maturin develop --release --extras=test,docs
python -m pip install --upgrade pytest pytest-dotenv pytest-cov furl hypothesis trustme astor pyopenssl isort pydirectory

- name: Create testdata directory
run: mkdir -p ./AISdb/testdata

- name: Run Tests
run: |
source ./AISdb/bin/activate
pytest ./aisdb/tests/ --ignore=./aisdb/tests/test_014_marinetraffic.py --maxfail=10
pytest ./aisdb/tests/ --ignore=./aisdb/tests/test_014_marinetraffic.py --ignore=./aisdb/tests/test_001_postgres.py --maxfail=10

- name: Clean Up
run: |
Expand Down Expand Up @@ -350,10 +352,13 @@ jobs:
maturin develop --release --extras=test,docs
python -m pip install --upgrade pytest pytest-dotenv pytest-cov furl hypothesis trustme astor pyopenssl isort pydirectory

- name: Create testdata directory
run: mkdir -p ./AISdb/testdata

- name: Run Tests
run: |
source ./AISdb/bin/activate
pytest ./aisdb/tests/ --ignore=./aisdb/tests/test_014_marinetraffic.py --maxfail=10
pytest ./aisdb/tests/ --ignore=./aisdb/tests/test_014_marinetraffic.py --ignore=./aisdb/tests/test_001_postgres.py --maxfail=10

- name: Clean Up
run: |
Expand Down Expand Up @@ -591,4 +596,4 @@ jobs:
# - name: Clean Up
# run: |
# rm -rf gh-pages
# rm -rf docs/dist_sphinx
# rm -rf docs/dist_sphinx
10 changes: 1 addition & 9 deletions aisdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,13 @@
'pyproject.toml'), 'r') as tomlfile:
__version__ = toml.load(tomlfile).get('project').get('version')

import sqlite3

if (sqlite3.sqlite_version_info[0] < 3
or (sqlite3.sqlite_version_info[0] <= 3
and sqlite3.sqlite_version_info[1] < 8)):
warnings.warn(
f"An outdated version of SQLite was found ({sqlite3.sqlite_version})")

sqlpath = os.path.abspath(os.path.join(os.path.dirname(__file__), 'aisdb_sql'))

import aisdb.web_interface

from .database.decoder import decode_msgs

from .database.dbconn import DBConn, SQLiteDBConn, PostgresDBConn
from .database.dbconn import DBConn, PostgresDBConn

from .database.dbqry import DBQuery

Expand Down
17 changes: 17 additions & 0 deletions aisdb/aisdb_sql/createtable_static_global_aggregate.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE TABLE IF NOT EXISTS static_global_aggregate (
mmsi INTEGER PRIMARY KEY,
imo INTEGER,
vessel_name TEXT,
ship_type INTEGER,
call_sign TEXT,
dim_bow INTEGER,
dim_stern INTEGER,
dim_port INTEGER,
dim_star INTEGER,
draught INTEGER,
destination TEXT,
eta_month INTEGER,
eta_day INTEGER,
eta_hour INTEGER,
eta_minute INTEGER
);
6 changes: 6 additions & 0 deletions aisdb/aisdb_sql/cte_aliases_global.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dynamic_global AS (
{}
),
static_global AS (
{}
)
13 changes: 13 additions & 0 deletions aisdb/aisdb_sql/cte_dynamic_clusteredidx_global.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SELECT
d.mmsi,
d.time,
d.utc_second,
d.longitude,
d.latitude,
d.rot,
d.sog,
d.cog,
d.heading,
d.maneuver
FROM ais_global_dynamic AS d
WHERE
16 changes: 16 additions & 0 deletions aisdb/aisdb_sql/cte_static_aggregate_global.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SELECT
agg.mmsi,
TRIM(agg.vessel_name) as vessel_name,
agg.ship_type,
agg.imo,
agg.dim_bow,
agg.dim_stern,
agg.dim_port,
agg.dim_star,
agg.draught,
agg.destination,
agg.eta_month,
agg.eta_day,
agg.eta_hour,
agg.eta_minute
FROM static_global_aggregate AS agg
16 changes: 16 additions & 0 deletions aisdb/aisdb_sql/new_insert_dynamic_clusteredidx.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
INSERT INTO ais_global_dynamic
(
mmsi,
time,
longitude,
latitude,
rot,
sog,
cog,
heading,
maneuver,
utc_second,
source
)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)
ON CONFLICT DO NOTHING;
23 changes: 23 additions & 0 deletions aisdb/aisdb_sql/new_insert_static.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
INSERT INTO ais_global_static (
mmsi,
time,
vessel_name,
ship_type,
call_sign,
imo,
dim_bow,
dim_stern,
dim_port,
dim_star,
draught,
destination,
ais_version,
fixing_device,
eta_month,
eta_day,
eta_hour,
eta_minute,
source
)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19)
ON CONFLICT DO NOTHING;
28 changes: 28 additions & 0 deletions aisdb/aisdb_sql/select_join_dynamic_static_clusteredidx_global.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
SELECT
dynamic.mmsi,
dynamic.time,
dynamic.utc_second,
dynamic.longitude,
dynamic.latitude,
dynamic.rot,
dynamic.sog,
dynamic.cog,
dynamic.heading,
dynamic.maneuver,
static.imo,
static.ship_type,
static.vessel_name,
static.dim_bow,
static.dim_stern,
static.dim_port,
static.dim_star,
static.draught,
static.destination,
static.eta_month,
static.eta_day,
static.eta_hour,
static.eta_minute,
ref.coarse_type_txt AS ship_type_txt
FROM ais_global_dynamic AS dynamic
LEFT JOIN ais_global_static AS static ON dynamic.mmsi = static.mmsi
LEFT JOIN ref ON static.ship_type = ref.coarse_type
6 changes: 3 additions & 3 deletions aisdb/aisdb_sql/timescale_createtable_dynamic.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS ais_{0}_dynamic
CREATE TABLE IF NOT EXISTS ais_global_dynamic
(
mmsi INTEGER NOT NULL,
time INTEGER NOT NULL,
Expand All @@ -15,14 +15,14 @@ CREATE TABLE IF NOT EXISTS ais_{0}_dynamic
);

SELECT create_hypertable(
'ais_{0}_dynamic',
'ais_global_dynamic',
'time',
partitioning_column => 'mmsi',
number_partitions => 4,
chunk_time_interval => 604800
);

ALTER TABLE ais_{0}_dynamic SET (
ALTER TABLE ais_global_dynamic SET (
timescaledb.compress = false,
timescaledb.compress_orderby = 'time ASC, latitude ASC, longitude ASC',
timescaledb.compress_segmentby = 'mmsi'
Expand Down
6 changes: 3 additions & 3 deletions aisdb/aisdb_sql/timescale_createtable_static.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS ais_{0}_static
CREATE TABLE IF NOT EXISTS ais_global_static
(
mmsi INTEGER NOT NULL,
time INTEGER NOT NULL,
Expand All @@ -23,14 +23,14 @@ CREATE TABLE IF NOT EXISTS ais_{0}_static
);

SELECT create_hypertable(
'ais_{0}_static',
'ais_global_static',
'time',
partitioning_column => 'mmsi',
number_partitions => 4,
chunk_time_interval => 604800
);

ALTER TABLE ais_{0}_static SET (
ALTER TABLE ais_global_static SET (
timescaledb.compress = false,
timescaledb.compress_orderby = 'time ASC',
timescaledb.compress_segmentby = 'mmsi'
Expand Down
3 changes: 3 additions & 0 deletions aisdb/database/create_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@

with open(os.path.join(sqlpath, 'createtable_static_aggregate.sql'), 'r') as f:
sql_aggregate = f.read()

with open(os.path.join(sqlpath, 'createtable_static_global_aggregate.sql'), 'r') as f:
sql_global_aggregate = f.read()
Loading
Loading