-
-
Notifications
You must be signed in to change notification settings - Fork 116
Mechanism for forcing column-type, over-riding auto-detection #100
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
Comments
The syntax for explicitly creating a table looks like this: db["cats"].create({
"id": int,
"name": str,
"weight": float,
}, pk="id") So using a dictionary of column name -> Python type here would be good. I think it becomes a new optional argument to Options:
I like the first two best. I'm leaning towards Maybe something like this: db["authors"].insert_all(
[{"id": 1, "name": "Sally", "score": "2"}],
pk="id",
not_null={"name", "score"},
defaults={"score": 1},
columns={"score": int, "weight": float}
) |
Reminder: the current list of arguments for those methods is: sqlite-utils/sqlite_utils/db.py Lines 951 to 967 in 13528fa
|
I'm going with |
As seen in dogsheep/github-to-sqlite#27 (comment) - there's a problem where you insert a record with a
None
value for a column and that column is created asTEXT
- but actually you intended it to be anINT
(as later examples will demonstrate).Some kind of mechanism for over-riding the detected types of columns would be useful here.
The text was updated successfully, but these errors were encountered: