Skip to content

Commit

Permalink
Merge branch 'main' of github.com:geoCML/tabor
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanDamron committed Sep 4, 2024
2 parents abe9980 + 0e4e7a5 commit 15b6bb6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ Tabor v0.2.0 can be downloaded directly from this repository (under Releases). A

`tabor read --file <path/to/file>` -> Converts a .tabor file into a PostGIS schema query.

`tabor write --file <path/to/file> --db <name_of_psql_db> --username <name of db user> --password <password of db user?> --host <host of psql db?> --port <port of psql db?>` -> Converts a PostGIS database to a .tabor file'
`tabor write --file <path/to/file> --db <name_of_psql_db> --username <name of db user> --password <password of db user?> --host <host of psql db?> --port <port of psql db?> --ignore <tables to ignore?>` -> Converts a PostGIS database to a .tabor file'

`tabor load --file <path/to/file> --db <name_of_psql_db> --username <name of db user> --password <password of db user?> --host <host of psql db?> --port <port of psql db?>` -> Loads a PostGIS database from a .tabor file.'
11 changes: 8 additions & 3 deletions src/tabor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
sys.tracebacklimit = -1


def load(file_path: str, db: str, username: str, password: str, host: str, port: str):
def load(file_path: str, db: str, username: str, password: str, host: str, port: str) -> None:
try:
db_connector = DBConnector(db, username, password, host, port)

Expand Down Expand Up @@ -40,7 +40,7 @@ def read(file_path: str) -> None:
print(tabor_src.to_psql())


def write(file_path: str, db: str, username: str, password: str, host: str, port: str) -> None:
def write(file_path: str, db: str, username: str, password: str, host: str, port: str, ignore_tables: list) -> None:
try:
data = {}
db_connector = DBConnector(db, username, password, host, port)
Expand All @@ -50,6 +50,9 @@ def write(file_path: str, db: str, username: str, password: str, host: str, port
schema = table.split(".")[0]
table_name = table.split(".")[1]

if table_name in ignore_tables:
continue

data[table] = {}
data[table]["fields"] = db_connector.get_fields_for_table(schema, table_name)
data[table]["constraints"] = db_connector.get_triggers_for_table(table_name)
Expand Down Expand Up @@ -79,6 +82,8 @@ def write(file_path: str, db: str, username: str, password: str, host: str, port
parser.add_argument('--password', help='The password of a database user.', default=None)
parser.add_argument('--host', help='The hostname of the PostGIS database to connect to.', default="localhost")
parser.add_argument('--port', help='The port of the PostGIS database to connect to.', default=5432)
parser.add_argument('--ignore', nargs="+", help='Any tables to ignore when writing to the .tabor file.', default=[])


args = parser.parse_args()

Expand All @@ -96,7 +101,7 @@ def write(file_path: str, db: str, username: str, password: str, host: str, port
if not args.username:
raise Exception("You must provide a PostGIS database user to connect to your database (--username)")

write(args.file, args.db, args.username, args.password, args.host, args.port)
write(args.file, args.db, args.username, args.password, args.host, args.port, args.ignore)
elif args.command == "load":
if not args.file:
raise Exception("You must provide one file to load from (--file)")
Expand Down

0 comments on commit 15b6bb6

Please sign in to comment.