question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importer fails with sqlite unable to insert default values

See original GitHub issue

Issue Summary

Tried importing a json from a GhostPro export, and got an error from the sqlite connector:

Import failed sqlite does not support inserting default values. Specify values explicitly or use the useNullAsDefault config flag. (see docs http://knexjs.org/#Builder-insert).

MacOS High Sierra (10.13.3) Chrome 65.0.3325.181 Export from GhostPro 1.22.1 Import to local install Ghost 1.22.3

NOTE: I have not yet tried downgrading local install to 1.22.1 and retrying import. (I haven’t had enough time, but it’s something I considered when gathering info for the bug report. I had assumed that GhostPro was running latest)

Steps to Reproduce

  1. Exported content from hosted ghost blog as json
  2. Install ghost locally
  3. Add user/blog, and try to import the json from step 1
  4. Import fails

Aside from trying to find the sqlite connector call and changing the code locally, I don’t know if there’s a way to set useNullAsDefault somewhere to try and re-import. Additionally, I think the error might be able to get caught and reworded for a friendlier user experience.

Technical details:

  • Ghost CLI Ver: 1.7.1
  • Ghost Version: 1.22.3
  • Node Version: 8.11.1
  • Browser/OS: Chrome 65.0.3325.181
  • Database: sqlite (bundled with ghost cli)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
jlohcommented, May 4, 2018

I’m able to reproduce this at the moment with 1.22.5 installed locally via ghost install local and an export from a Ghost(Pro) blog.

Edit: I’ve got around this by adding "useNullAsDefault": true to my config.development.json and I’m able to import content. I do get a whole lot of errors like this though:

Post: Entry was imported, but we were not able to resolve the following user references: published_by. The user does not exist, fallback to owner user.

The database portion in my config.development.json file ends up looking like this:

"database": {
  "client": "sqlite3",
  "connection": {
    "filename": "/nobackup/ghost/content/data/ghost-local.db"
  },
  "useNullAsDefault": true
},
2reactions
kirrg001commented, Jul 12, 2018

@docrinehart see SQlite3 config example https://docs.ghost.org/docs/config#section-sqlite3.

Leaving this open. I need to understand if we have to set a default for this value. I thought it’s only required for our test env and our test fixtures. I don’t remember. Will check when i have time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to insert rows in SQLite using default values?
I can't figure out how to omit certain values and let the database use the default for that column. For example, the complete...
Read more >
INSERT - SQLite
DEFAULT VALUES statement inserts a single new row into the named table. Each column of the new row is populated with its default...
Read more >
SQLite UNIQUE Constraint
In this tutorial, you will learn how to use the SQLite UNIQUE constraint to ensure all values in a column or a group...
Read more >
Insert row into SQLite table with default values in ... - YouTrack
1. Create a table within a SQLite database that has field with default values, e.g.: CREATE TABLE testtable ( · 2. Open Table...
Read more >
pandas.DataFrame.to_sql — pandas 1.5.2 documentation
fail : Raise a ValueError. replace: Drop the table before inserting new values. append: Insert new values to the existing table. indexbool, default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found