Skip to content
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

DATETIME interface: unsupported driver #99

Closed
arcynum opened this issue Apr 24, 2015 · 1 comment
Closed

DATETIME interface: unsupported driver #99

arcynum opened this issue Apr 24, 2015 · 1 comment

Comments

@arcynum
Copy link

arcynum commented Apr 24, 2015

I am attempting to build a physical table downloading service.

I am having problems when trying to process SQL Server DATETIME fields in this way.

I am experincing the following error when running the following code:
sql: Scan error on column index 8: unsupported driver -> Scan pair: time.Time -> *[]uint8

I have looked around and it seems this is an issue other drivers have encountered, but I can't point at a specific solution.

Being able to assign a datetime value through Scan() would be extremely useful.

// Create and run the database query.
query, err := dbConnection.Query("SELECT * FROM table")
if err != nil {
    log.Fatal(err)
}
defer query.Close()

// Get the queries columns
cols, err := query.Columns()
if err != nil {
    log.Fatal(err)
}

// Byte data (so NULL fields can be handled later)
byteData := make([][]byte, len(cols))

// Interface for the scan
destination := make([]interface{}, len(cols))

// Assign the destination interface points to the byte data.
for i, _ := range byteData {
    destination[i] = &byteData[i]
}

// Parse query results.
for query.Next() {
    err := query.Scan(destination...)
    if err != nil {
        log.Fatal(err) // Bombing out here.
    }
}
@denisenkom
Copy link
Owner

I think you should scan DATETIME into time.Time and then convert it into some binary format of your choosing.

gabrielcorado pushed a commit to gravitational/go-mssqldb that referenced this issue Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants