Comments (4)
I'm not sure I understand the problem. Regarding the constructor, are you using dbmate as a library or a CLI?
Dbmate is intended to take a URL connection string, not a MySQL DSN. Is there a problem with using a URL such as mysql://boulder@localhost/boulder_test?parseTime=true
?
from dbmate.
I'm not sure I understand the problem. Regarding the constructor, are you using dbmate as a library or a CLI?
As a library.
Is there a problem with using a URL such as
mysql://boulder@localhost/boulder_test?parseTime=true
?
No but there is a problem with this, for example:
sqlConfig := &mysql.Config{
User: "root",
Passwd: "secret",
Addr: "localhost:3306",
Net: "tcp",
DBName: "mysql",
AllowNativePasswords: true,
}
_, err := url.Parse("mysql://" + sqlConfig.FormatDSN())
// DNS: root:secret@tcp(localhost:3306)/mysql?maxAllowedPacket=0
// parse mysql://root:secret@tcp(localhost:3306)/mysql?maxAllowedPacket=0: invalid port ":3306)" after host
https://play.golang.org/p/E12R0IG4X_7
Dbmate is intended to take a URL connection string, not a MySQL DSN.
Ok, that's not an issue if this is by design then. I just think it would be good to follow MySQL DSN format.
from dbmate.
I see. As you noticed, when using dbmate as an API the libraries assume that your connection string is a valid URL. We assume that any database connection string can be formatted as a url (and in fact many/most languages can support a url connection string).
The DSN format you're using above seems to be specific to the Go MySQL driver, correct? I can't find any references to it in the MySQL documentation. The reason I ask is that if it were a standard cross-language MySQL connection string format then it might make sense for us to support it (even though this would require some significant refactoring), but if it's unique to the Go MySQL driver then I think it makes more sense to leave this out.
In the meantime, you can generate a valid connection URL from your mysql.Config
very easily using fmt.Sprintf
.
from dbmate.
I looked further into this. Supporting arbitrary strings instead of a url.URL
requires pretty significant refactoring since we need to be able to parse the connection string before providing it to the driver (e.g. for connecting to the root database), and each go database driver expects different things.
I'm not convinced this is worth adding support for considering the workaround you suggested is pretty simple. Dbmate is designed to support multiple databases with a standardized interface, and for now it's simpler if we keep the interface requiring a URL.
from dbmate.
Related Issues (20)
- Dbmate Unable to Create SchemaMigrations Table HOT 6
- Postgres Schemas with special characters have DBMate create migration tables then cannot find it again
- ClickHouse Cloud https connection doesn't work HOT 2
- Getting pq: syntax error at or near "transaction" when running migration with transaction:false HOT 7
- The migration lock is not released after terminating the migration HOT 2
- Comments (on columns) that include line breaks are never created. HOT 1
- dbmate requires each migration to define a down block with '-- migrate:down' when it defined HOT 5
- No Zookeeper configuration in server config
- Support all DSN variants for clickhouse DATABASE_URL HOT 8
- Wait for Postgres to be ready HOT 3
- $PGHOST & $PGPORT are not respected. HOT 2
- Add a section to the README documenting how environment variables are used by dbmate
- Table aliases don't work with ClickHouse HOT 2
- Add `--wait-interval` and `$DBMATE_WAIT_INTERVAL` to make wait interval configurable at runtime HOT 7
- The latest release is missing all the binaries HOT 2
- Could not open extension control file "/share/extension/http.control" HOT 2
- Embedded FS on Windows HOT 2
- `make docker-all` timeout when run locally. HOT 1
- DBMate always delets my database anytime I run a migration HOT 1
- Library methods not using context
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbmate.