https://github.com/whizsid/osm-to-sql
A command line tool to convert XML open street map data to SQL.
https://github.com/whizsid/osm-to-sql
cli foreign-key-constraints osm pinned sql-files
Last synced: 6 months ago
JSON representation
A command line tool to convert XML open street map data to SQL.
- Host: GitHub
- URL: https://github.com/whizsid/osm-to-sql
- Owner: whizsid
- License: mit
- Created: 2019-09-30T19:22:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-15T20:04:47.000Z (over 5 years ago)
- Last Synced: 2025-09-08T14:46:59.932Z (7 months ago)
- Topics: cli, foreign-key-constraints, osm, pinned, sql-files
- Language: Rust
- Homepage:
- Size: 61.5 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# osm-to-sql
---



---
Simple OSM XML data to SQL converter command. This command will create 7 SQL files with foreign key constraints. You can use these SQL files with MySQL/ SQLite or any other SQL server.
## Installation
Currently only supporting to linux distros.
### Arch Based Distros
Install it from arch user repository.
```
yaourt -S osm-to-sql
```
### Debian Based Distros
Download the `.deb` file from [here](https://github.com/whizsid/osm-to-sql/releases/download/0.1.3/osm-to-sql_0.1.3_amd64.deb) and install it using `dpkg`.
```
dpkg -i ./osm-to-sql_0.1.3_amd64.deb
```
## Other Distros
Download the standalone binary file from [here](https://github.com/whizsid/osm-to-sql/releases/download/0.1.3/osm-to-sql) and run it.
## Usage
This is the default help menu for the command line tool.
```
Usage:
osm-to-sql [OPTIONS] -i -d
OPTIONS:
-i Input open street map file in XML format.
-d Output directory to save output sql files.
-r Maximum rows per one SQL insert query. [400]
-h Prints help information
-g Do not use INSERT IGNORE queries
```
## Table mappings
All tables have foreign key constraints and all tables will creating automatically with these SQL files. And please import with the following order when you importing to your database server.
```
1.nodes
id,lat,lng,version,changeset,user,uid,visible,date_time
2.ways
id,version,changeset,user,uid,visible,date_time
3.way_nodes
way_id,node_id
-- way_id = ways(id)
-- node_id = nodes(id)
4.relations
id,version,changeset,user,uid,visible,date_time
5.relation_members
rm_id,relation_id,node_id,way_id,role
-- relation_id = relations(id)
-- node_id = nodes(id)
-- way_id = ways(id)
-- sub_relation_id = relations(id)
6.tags
id,name
7.ref_tags
rt_id,tag_id,node_id,relation_id,way_id,value
-- tag_id = tags(id)
-- node_id = nodes(id)
-- relation_id = relations(id)
-- way_id = ways(id)
```
Sample output files in the `sample/output` folder.
## Contirbutions
All contibutions and issues are welcome. Please help me to make this tool faster and powerfull.