Stop using NULL in the database
It's simply easier not to with the stock SQL engine
This commit is contained in:
parent
c0d3cc0416
commit
60dbcab706
2 changed files with 8 additions and 8 deletions
|
@ -10,7 +10,7 @@ SQLITEFILE = sys.argv[2]
|
|||
with open(CSVFILE) as csvf:
|
||||
csv_reader = csv.reader(csvf)
|
||||
|
||||
x = list(map(lambda x: (str(uuid.uuid4()), *map(lambda y: (y if y != "" else None), x)), list(csv_reader)[1:]))
|
||||
x = list(map(lambda x: (str(uuid.uuid4()), *map(lambda y: (y if y != "" else ""), x)), list(csv_reader)[1:]))
|
||||
db = sqlite3.connect(SQLITEFILE)
|
||||
db.executemany(
|
||||
"""INSERT INTO articles("id", "url", "title", "description", "image_url", "date", "hacker_news_url") VALUES (?, ?, ?, ?, ?, ?, ?)""",
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
"github.com/google/uuid"
|
||||
"time"
|
||||
)
|
||||
|
||||
type NewArticle struct {
|
||||
URL string `validate:"required,url"`
|
||||
Title string `validate:"required"`
|
||||
Description string `db:"description,nullzero"`
|
||||
ImageURL string `db:"image_url,nullzero"`
|
||||
Date time.Time `validate:"required"`
|
||||
URL string `validate:"required,url"`
|
||||
Title string `validate:"required"`
|
||||
Description string `db:"description"`
|
||||
ImageURL string `db:"image_url"`
|
||||
Date time.Time `validate:"required"`
|
||||
}
|
||||
|
||||
type Article struct {
|
||||
NewArticle
|
||||
ID uuid.UUID
|
||||
HackerNewsURL string `db:"hacker_news_url,nullzero"`
|
||||
HackerNewsURL string `db:"hacker_news_url"`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue