-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add oracle driver to support oracle databases (#201)
* feat(client): add oracle drive to support oracle databases 110 * feat(connection): build the connection string to oracle * feat(client): add support for oracle from the client perspective * refactor(oracle): add some changes to align with the oracle standard * build(compose): add a oracle contianer to the compose file * build(makefile): add a target command to connect with oracle * feat(oracle): add parsing to build a url to connect with an oracle database * docs(readme): add some docs on how to use dblab to connect with an oracle database * feat(config): add support for the oracle driver to the config file feature feat(config): add missing files * docs(readme): add an example to describe how to add the parameters to connect with oracle through the config file * feat(form): add oracle support to the form mini tui app
- Loading branch information
1 parent
be31a85
commit bc13da4
Showing
19 changed files
with
462 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package client | ||
|
||
import ( | ||
"strings" | ||
|
||
sq "github.com/Masterminds/squirrel" | ||
_ "github.com/sijms/go-ora/v2" | ||
) | ||
|
||
// oracle struct is in charge of perform all the oracle related queries. | ||
type oracle struct{} | ||
|
||
// a validation to see if oracle is implementing databaseQuerier. | ||
var _ databaseQuerier = (*oracle)(nil) | ||
|
||
// returns a pointer to a oracle struct, it receives an schema as a parameter. | ||
func newOracle() *oracle { | ||
o := oracle{} | ||
|
||
return &o | ||
} | ||
|
||
// ShowTables returns a query to retrieve all the tables. | ||
func (p *oracle) ShowTables() (string, []interface{}, error) { | ||
query := "SELECT table_name FROM user_tables" | ||
return query, nil, nil | ||
} | ||
|
||
// TableStructure returns a query string to get all the relevant information of a given table. | ||
func (p *oracle) TableStructure(tableName string) (string, []interface{}, error) { | ||
query := sq.Select("*"). | ||
From("user_tab_columns"). | ||
Where(sq.Eq{"table_name": strings.ToUpper(tableName)}). | ||
OrderBy("column_id"). | ||
PlaceholderFormat(sq.Colon) | ||
|
||
sql, args, err := query.ToSql() | ||
if err != nil { | ||
return "", nil, err | ||
} | ||
|
||
return sql, args, nil | ||
} | ||
|
||
// Constraints returns all the constraints of a given table. | ||
func (p *oracle) Constraints(tableName string) (string, []interface{}, error) { | ||
query := sq.Select( | ||
`constraint_name`, | ||
`constraint_type`, | ||
). | ||
From("user_constraints"). | ||
Where(sq.Eq{"table_name": tableName}). | ||
PlaceholderFormat(sq.Colon) | ||
|
||
sql, args, err := query.ToSql() | ||
if err != nil { | ||
return "", nil, err | ||
} | ||
|
||
return sql, args, err | ||
} | ||
|
||
// Indexes returns the indexes of a table. | ||
func (p *oracle) Indexes(tableName string) (string, []interface{}, error) { | ||
sql, args, err := sq.Select("*"). | ||
From("all_indexes"). | ||
Where(sq.Eq{"table_name": tableName}). | ||
PlaceholderFormat(sq.Colon). | ||
ToSql() | ||
if err != nil { | ||
return "", nil, err | ||
} | ||
|
||
return sql, args, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.