{"id":22018131,"url":"https://github.com/rvflash/awql-driver","last_synced_at":"2025-05-07T03:11:24.491Z","repository":{"id":57501579,"uuid":"68103614","full_name":"rvflash/awql-driver","owner":"rvflash","description":"AWQL driver for Go's sql package","archived":false,"fork":false,"pushed_at":"2018-10-01T19:39:35.000Z","size":60,"stargazers_count":12,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T05:41:28.489Z","etag":null,"topics":["adwords-api","awql","golang-sql-driver"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rvflash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-13T11:49:14.000Z","updated_at":"2020-10-05T11:01:37.000Z","dependencies_parsed_at":"2022-09-10T16:41:17.654Z","dependency_job_id":null,"html_url":"https://github.com/rvflash/awql-driver","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fawql-driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fawql-driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fawql-driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fawql-driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rvflash","download_url":"https://codeload.github.com/rvflash/awql-driver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252804220,"owners_count":21806771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adwords-api","awql","golang-sql-driver"],"created_at":"2024-11-30T05:10:03.188Z","updated_at":"2025-05-07T03:11:24.445Z","avatar_url":"https://github.com/rvflash.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Awql Database Driver\n\n[![GoDoc](https://godoc.org/github.com/rvflash/awql-driver?status.svg)](https://godoc.org/github.com/rvflash/awql-driver)\n[![Build Status](https://img.shields.io/travis/rvflash/awql-driver.svg)](https://travis-ci.org/rvflash/awql-driver)\n[![Code Coverage](https://img.shields.io/codecov/c/github/rvflash/awql-driver.svg)](http://codecov.io/github/rvflash/awql-driver?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/rvflash/awql-driver)](https://goreportcard.com/report/github.com/rvflash/awql-driver)\n\n\nAWQL driver for Go's sql package.\n\n\n## Installation\n\nSimple install the package to your $GOPATH with the go tool:\n\n```bash\n~ $ go get -u github.com/rvflash/awql-driver\n```\n\n## Usage\n\nAWQL Driver is an implementation of Go's `database/sql/driver` interface.\nYou only need to import the driver and can use the full database/sql API then.\n\nUse `awql` as `driverName` and a valid [DSN](#data-source-name) as `dataSourceName`:\n\n```go\nimport \"database/sql\"\nimport _ \"github.com/rvflash/awql-driver\"\n\ndb, err := sql.Open(\"awql\", \"AdwordsID:APIVersion|DeveloperToken|AccessToken\")\n```\n\n## Data Source Name\n\nThe Data Source Name has two common formats, the optional parts are marked by squared brackets:\n\n#### `Minimal`\n```\nAdwordsID|DeveloperToken[|AccessToken]\n```\n#### `OAuth credentials`\n```\nAdwordsID|DeveloperToken[|ClientID|ClientSecret|RefreshToken]\n```\n\nThe first part with `AdwordsID` can contains Adwords API options. A DSN in its fullest form:\n```\nAdwordsID[:APIVersion:SupportsZeroImpressions:SkipColumnHeader:UseRawEnumValues]|DeveloperToken[|AccessToken][|ClientID|ClientSecret|RefreshToken]\n```\n\nAlternatively, [NewDSN](https://godoc.org/github.com/rvflash/awql-driver#Dsn) can be used to create a DSN string by filling a struct.\n\n\n#### `AdwordsID`\n\nThe client customer ID is the account number of the AdWords client account you want to manage via the API, usually in the form 123-456-7890.\n\n#### `APIVersion`\n\n```\nType:           string\nValid Values:   \u003cversion\u003e\nDefault:        v201809\n```\nVersion of the Adwords API to use.\n\n#### `SupportsZeroImpressions`\n\n```\nType:           bool\nValid Values:   true, false\nDefault:        false\n```\nIf true, report output will include rows where all specified metric fields are zero, provided the requested fields and predicates support zero impressions.\nIf false, report output will not include such rows. \nThus, even if this header is false and the Impressions of a row is zero, the row is still returned in case any of the specified metric fields have non-zero values. \n\n#### `SkipColumnHeader`\n\n```\nType:           bool\nValid Values:   true, false\nDefault:        false\n```\nIf true, report output will not include a header row containing field names.\nIf false or not specified, report output will include the field names.\n\n#### `UseRawEnumValues`\n\n```\nType:           bool\nValid Values:   true, false\nDefault:        false\n```\nSet to true if you want the returned format to be the actual enum value, for example, \"IMAGE_AD\" instead of \"Image ad\".\nSet to false or omit this header if you want the returned format to be the display value.\n\n#### `DeveloperToken`\n\nThe developer token identifies your app to the AdWords API.\nOnly approved tokens can connect to the API for production AdWords accounts; pending tokens can connect only to test accounts.\n\n#### `AccessToken`\n\nUse to grant connection to Google API\n\n#### `ClientID`\n\nClient identifier, used to connect to Adwords with OAuth2.\n\n#### `ClientSecret`\n\nClient secret, used to connect to Adwords with OAuth2.\n\n#### `RefreshToken`\n\nBecause OAuth2 access expires after a limited time, an OAuth2 refresh token is used to automatically renew OAuth2 access.\n\n\n## Examples\n\n### Simple Awql query\n \n```go\n// Ignores errors for the demo.\nquery := \"SELECT ExternalCustomerId, AccountDescriptiveName FROM ACCOUNT_PERFORMANCE_REPORT\"\ndb, _ := sql.Open(\"awql\", \"123-456-7890|dEve1op3er7okeN|ya29.Acc3ss-7ok3n\")\nstmt, _ := db.Query(query)\nfor stmt.Next() {\n    var id int\n    var name string\n    stmt.Scan(\u0026id, \u0026name)\n    fmt.Printf(\"%v: %v\\n\", id, name)\n    // Output: 1234567890: Rv\n}\n```\n \n### Awql query row with arguments\n\n```go\n// Ignores errors for the demo.\nvar name string\nquery := \"SELECT CampaignName FROM CAMPAIGN_PERFORMANCE_REPORT Where CampaignId = ?\"\nrow := db.QueryRow(query, 123456789)\nrow.Scan(\u0026name)\nfmt.Printf(\"%v\\n\", name)\n// Output: Campaign #19\n```\n\n### Advanced sample\n\n```go\n// Instantiates a data source name.\ndsn := awql.NewDsn(\"123-456-7890\")\ndsn.DeveloperToken = \"dEve1op3er7okeN\"\ndsn.ClientID = \"1234567890-Aw91.apps.googleusercontent.com\"\ndsn.ClientSecret = \"C13nt5e0r3t\"\ndsn.RefreshToken = \"1/n-R3fr35h70k3n\"\n\n// Ignores errors for the demo.\nquery := \"SELECT ConversionTypeName, AllConversions, ConversionValue FROM CRITERIA_PERFORMANCE_REPORT DURING LAST_7_DAYS\"\ndb, _ := sql.Open(\"awql\", dsn.String())\nstmt, _ := db.Query(query)\ncols, _ := stmt.Columns()\nfmt.Printf(\"%q\\n\", cols)\n// Output: [\"Conversion name\" \"All conv.\" \"Total conv. value\"]\n\n// Copy references into the slice\nsize := len(cols)\nvals := make([]string, size)\nints := make([]interface{}, size)\nfor i := range ints {\n    ints[i] = \u0026vals[i]\n}\nfor stmt.Next() {\n    stmt.Scan(ints...)\n    fmt.Printf(\"%q\\n\", vals)\n}\n// Output:\n// [\"Transactions (Phone)\" \"6.0\" \"362.33\"]\n// [\"Transactions (Web)\" \"1.0\" \"89.3\"]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frvflash%2Fawql-driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frvflash%2Fawql-driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frvflash%2Fawql-driver/lists"}