-
Notifications
You must be signed in to change notification settings - Fork 2
Add support for SAP HANA. #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| services: | ||
| # HANA Express Database for testing | ||
| hanaexpress: | ||
| image: saplabs/hanaexpress:latest | ||
| container_name: baton-hanaexpress-test | ||
| hostname: hanaexpress | ||
| ulimits: | ||
| nofile: | ||
| soft: 1048576 | ||
| hard: 1048576 | ||
| sysctls: | ||
| kernel.shmmax: 1073741824 | ||
| net.ipv4.ip_local_port_range: 40000 60999 | ||
| kernel.shmall: 8388608 | ||
| ports: | ||
| - "39013:39013" | ||
| - "39017:39017" | ||
| - "39041:39041" | ||
| - "39042:39042" | ||
| - "39043:39043" | ||
| - "39044:39044" | ||
| - "39045:39045" | ||
| - "1128:1128" | ||
| - "1129:1129" | ||
| - "59013:59013" | ||
| - "59014:59014" | ||
| command: > | ||
| --passwords-url file:///hana/mounts/password.json | ||
| --agree-to-sap-license | ||
|
|
||
| volumes: | ||
| - ./test/hanaexpress:/hana/mounts |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| --- | ||
| app_name: HANA Express Test | ||
|
|
||
| connect: | ||
| dsn: "hdb://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}" | ||
|
|
||
| resource_types: | ||
| user: | ||
| name: "User" | ||
| description: "A user within the SAP HANA system" | ||
| list: | ||
| query: | | ||
| SELECT | ||
| USER_ID, | ||
| USER_NAME, | ||
| CASE | ||
| WHEN USER_DEACTIVATED = 'TRUE' THEN 'inactive' | ||
| ELSE 'active' | ||
| END as STATUS, | ||
| CREATE_TIME, | ||
| LAST_SUCCESSFUL_CONNECT, | ||
| COMMENTS | ||
| FROM | ||
| "SYS"."USERS" | ||
| ORDER BY USER_ID | ||
| LIMIT ?<Limit> OFFSET ?<Offset> | ||
| # Pagination configuration | ||
| pagination: | ||
| strategy: "offset" | ||
| primary_key: "USER_ID" | ||
| # Mapping of query results to resource fields | ||
| map: | ||
| id: ".USER_ID" | ||
| display_name: ".USER_NAME" | ||
| description: ".USER_NAME" | ||
| # Extra attributes (traits) for the user resource | ||
| traits: | ||
| user: | ||
| status: .STATUS | ||
| login: .USER_NAME | ||
| # Email addresses | ||
| # emails: | ||
| # - ".email" | ||
| # account_type: ".account_type" | ||
| last_login: .LAST_SUCCESSFUL_CONNECT | ||
| created_at: .CREATE_TIME | ||
| profile: | ||
| comments: .COMMENTS | ||
| user_id: .USER_ID | ||
| created_at: .CREATE_TIME | ||
| last_login: .LAST_SUCCESSFUL_CONNECT |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||||||||||||||||||||||||||||||||||
| package hdb | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||||||||||||
| "context" | ||||||||||||||||||||||||||||||||||||||
| "database/sql" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| _ "github.com/SAP/go-hdb/driver" | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| func Connect(ctx context.Context, dsn string) (*sql.DB, error) { | ||||||||||||||||||||||||||||||||||||||
| db, err := sql.Open("hdb", dsn) | ||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| return db, nil | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+10
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add documentation for the exported function. The exported Apply this diff to add documentation: +// Connect establishes a connection to a SAP HANA database using the provided DSN.
+// It returns a configured sql.DB instance or an error if the connection cannot be opened.
func Connect(ctx context.Context, dsn string) (*sql.DB, error) {
db, err := sql.Open("hdb", dsn)
if err != nil {
return nil, err
}
return db, nil
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "master_password" : "HXEHana1" | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.