Documentation
¶
Index ¶
- Constants
- Variables
- func BytesToUnicodeEscapes(b []byte) string
- func IsFullyUnicodeEscaped(s string) bool
- func Trace(pattern string, args ...interface{})
- func TraceOff()
- func TraceOn(w io.Writer)
- func UnescapeUnicode(s string) ([]byte, error)
- type Connection
- type D1Resp
- type D1RespError
- type D1RespMessage
- type D1RespQueryResult
- type D1RespQueryResultMeta
- type D1RespQueryResults
- type D1RespResultInfo
- type ParameterizedStatement
Constants ¶
View Source
const (
API_TOKEN apiOps
)
View Source
const DriverName = "d1"
Variables ¶
View Source
var ( ErrInvalidAPI = errors.New("invalid api") ErrClosed = errors.New("d1: connection is closed") ErrEmptyDSN = errors.New("dsn is empty") ErrShortDSN = errors.New("dsn specified is impossibly short") ErrNotD1 = errors.New("dsn does not start with 'd1'") ErrInvalidDB = errors.New("invalid database id") )
Functions ¶
func BytesToUnicodeEscapes ¶
BytesToUnicodeEscapes 将 []byte 转换为 Unicode 转义序列字符串
func IsFullyUnicodeEscaped ¶
func TraceOff ¶
func TraceOff()
TraceOff turns off tracing output. Once you call TraceOff(), no further info is sent to the io.Writer, unless it is TraceOn'd again.
func TraceOn ¶
TraceOn turns on tracing output to the io.Writer of your choice.
Trace output is very detailed and verbose, as you might expect.
Normally, you should run with tracing off, as it makes absolutely no concession to performance and is intended for debugging/dev use.
func UnescapeUnicode ¶
UnescapeUnicode 将包含Unicode转义序列的字符串转换为对应的[]byte。
Types ¶
type Connection ¶
type Connection struct { ID string // generated in init() // contains filtered or unexported fields }
func Open ¶
func Open(dsn string) (conn *Connection, err error)
Open opens a new connection to the database. The dsn looks like:
d1://apiToken:accountId@databaseId?timeout=10
func (*Connection) Close ¶
func (conn *Connection) Close()
Close will mark the connection as closed. It is safe to be called multiple times.
func (*Connection) VerifyApiTokenContext ¶
func (c *Connection) VerifyApiTokenContext(ctx context.Context) (err error)
func (*Connection) WriteParameterizedContext ¶
func (c *Connection) WriteParameterizedContext(ctx context.Context, stmt ParameterizedStatement) (resp D1Resp, err error)
type D1Resp ¶
type D1Resp struct { Errors []D1RespError `json:"errors"` Messages []D1RespMessage `json:"messages"` Result []*D1RespQueryResult `json:"result"` ResultInfo *D1RespResultInfo `json:"result_info"` Success bool `json:"success"` AuditlogId string `json:"-"` }
type D1RespError ¶
type D1RespMessage ¶
type D1RespQueryResult ¶
type D1RespQueryResult struct { Meta D1RespQueryResultMeta `json:"meta"` Results D1RespQueryResults `json:"results"` }
type D1RespQueryResultMeta ¶
type D1RespQueryResultMeta struct { ChangedDb bool `json:"changed_db"` Changes int64 `json:"changes"` Duration float64 `json:"duration"` LastRowID int64 `json:"last_row_id"` RowsRead int64 `json:"rows_read"` RowsWritten int64 `json:"rows_written"` ServedBy string `json:"served_by"` SizeAfter int64 `json:"size_after"` }
type D1RespQueryResults ¶
type D1RespQueryResults struct { Columns []string `json:"columns"` Rows [][]interface{} `json:"rows"` }
type D1RespResultInfo ¶
type ParameterizedStatement ¶
type ParameterizedStatement struct { SQL string `json:"sql"` Params []interface{} `json:"params"` }
Click to show internal directories.
Click to hide internal directories.