MCPcopy Create free account
hub / github.com/upper/db / LookupName

Method LookupName

adapter/sqlite/database.go:100–128  ·  view source on GitHub ↗
(sess sqladapter.Session)

Source from the content-addressed store, hash-verified

98}
99
100func (*database) LookupName(sess sqladapter.Session) (string, error) {
101 connURL := sess.ConnectionURL()
102 if connURL != nil {
103 connURL, err := ParseURL(connURL.String())
104 if err != nil {
105 return "", err
106 }
107 return connURL.Database, nil
108 }
109
110 // sess.ConnectionURL() is nil if using sqlite.New
111 rows, err := sess.SQL().Query(exql.RawSQL("PRAGMA database_list"))
112 if err != nil {
113 return "", err
114 }
115 dbInfo := struct {
116 Name string `db:"name"`
117 File string `db:"file"`
118 }{}
119
120 if err := sess.SQL().NewIterator(rows).One(&dbInfo); err != nil {
121 return "", err
122 }
123 if dbInfo.File != "" {
124 return dbInfo.File, nil
125 }
126 // dbInfo.File is empty if in memory mode
127 return dbInfo.Name, nil
128}
129
130func (*database) TableExists(sess sqladapter.Session, name string) error {
131 q := sess.SQL().

Callers

nothing calls this directly

Calls 8

RawSQLFunction · 0.92
ParseURLFunction · 0.70
ConnectionURLMethod · 0.65
StringMethod · 0.65
QueryMethod · 0.65
SQLMethod · 0.65
OneMethod · 0.65
NewIteratorMethod · 0.65

Tested by

no test coverage detected