Skip to content

Commit

Permalink
3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
infeeeee committed Sep 17, 2024
1 parent 012d5b6 commit b93c3a7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: Unit tests on Cloud
strategy:
matrix:
python-version: ["3.12"]
python-version: ["3.9", "3.12"]
environment: ["cloud"]

uses: ./.github/workflows/action-test.yml
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.venv
/.idea
*.egg-info
__pycache__
testrun.py
Expand Down
5 changes: 3 additions & 2 deletions nocodb/Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ def get_table_by_title(self, title: str) -> Table:
raise Exception(f"Table with name {title} not found!")

def create_table(self, table_name: str,
columns: list[dict] = [], add_default_columns: bool = True,
columns: list[dict] | None = None, add_default_columns: bool = True,
**kwargs) -> Table:
kwargs["table_name"] = table_name

if not columns:
kwargs["columns"] = Column.get_id_metadata()
elif add_default_columns:
columns.extend(Column.get_id_metadata())
kwargs["columns"] = columns
kwargs["columns"] = columns
else:
kwargs["columns"] = columns

Expand Down
8 changes: 4 additions & 4 deletions nocodb/Record.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ def __init__(self, table: "Table", **kwargs) -> None:
self.metadata = kwargs

def link_record(self, column: Column, link_record: "Record") -> bool:
path = f"tables/{self.table.table_id}/links/{
column.column_id}/records/{self.record_id}"
path = (f"tables/{self.table.table_id}/links/" +
f"{column.column_id}/records/{self.record_id}")
r = self.noco_db.call_noco(path=path,
method="POST", json={"Id": link_record.record_id})

return r.json()

def link_records(self, column: Column, link_records: list["Record"]) -> bool:
path = f"tables/{self.table.table_id}/links/{
column.column_id}/records/{self.record_id}"
path = (f"tables/{self.table.table_id}/links/" +
f"{column.column_id}/records/{self.record_id}")
r = self.noco_db.call_noco(path=path,
method="POST", json=[{"Id": l.record_id} for l in link_records])

Expand Down
3 changes: 2 additions & 1 deletion nocodb/Table.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def delete(self) -> bool:
logger.debug(f"Table {self.title} deleted")
return r.json()

def get_records(self, params: dict = {}) -> list[Record]:
def get_records(self, params: dict | None = None) -> list[Record]:
params = params or {}

if any([p in params for p in ["offset", "limit"]]):
get_all_records = False
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "py-nocodb"
version = "0.0.1"
description = "Python client for NocoDB API v2"
readme = "README.md"
requires-python = ">=3.12"
requires-python = ">=3.9"
license = { file = "LICENSE" }
authors = [{ name = "infeeeee", email = "[email protected]" }]
maintainers = [{ name = "infeeeee", email = "[email protected]" }]
Expand Down

0 comments on commit b93c3a7

Please sign in to comment.