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.

Importing CTFd-exported ZIP gives DateTime error

See original GitHub issue

Environment:

  • CTFd Version/Commit: master
  • Operating System: Debian Testing
  • Web Browser and Version: N/A

What happened? In trying to import a ZIP file that was previously exported with CTFd, an error is thrown stating “SQLite DateTime type only accepts Python”

What did you expect to happen? I expected the data to import successfully

How to reproduce your issue sudo python import.py ~/CTF-DATA.zip

Any associated stack traces or error logs

> sudo python import.py ~/CTF-DATA.zip 
/*\ CTFd has updated and must update the database! /*\
/*\ Please backup your database before proceeding! /*\
/*\ CTFd maintainers are not responsible for any data loss! /*\
Run database migrations (Y/N)y
 * Loaded module, <module 'CTFd.plugins.challenges' from '/var/www/ctfd/CTFd/plugins/challenges/__init__.pyc'>
 * Loaded module, <module 'CTFd.plugins.keys' from '/var/www/ctfd/CTFd/plugins/keys/__init__.pyc'>
Traceback (most recent call last):
  File "import.py", line 9, in <module>
    import_ctf(sys.argv[1])
  File "/var/www/ctfd/CTFd/utils.py", line 802, in import_ctf
    table.insert(entry)
  File "/usr/local/lib/python2.7/dist-packages/dataset/table.py", line 80, in insert
    res = self.db.executable.execute(self.table.insert(row))
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 945, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1121, in _execute_context
    None, None)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
    exc_info
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1116, in _execute_context
    context = constructor(dialect, self, conn, *args)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 623, in _init_compiled
    param.append(processors[key](compiled_params[key]))
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/dialects/sqlite/base.py", line 610, in process
    raise TypeError("SQLite DateTime type only accepts Python "
sqlalchemy.exc.StatementError: (exceptions.TypeError) SQLite DateTime type only accepts Python datetime and date objects as input. [SQL: u'INSERT INTO teams (name, email, password, website, affiliation, country, bracket, banned, verified, admin, joined) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)']

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ColdHeatcommented, Dec 3, 2017

CTFd exports should be able to go between databases. They should be viewed as a single portable file that can go between CTFd instances.

I think there’s enough here to warrant some kind of fix so I’ll try to reproduce and come up with some general solution.

0reactions
ColdHeatcommented, Dec 3, 2017

In that case I would probably see if you can modify the date format, or downgrade to 1.0.2, import, and then upgrade CTFd to master and run migrations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL Server Import Export wizard - error for datetime
The best thing to do is to import everything to a staging table with all column data types as NVARCHAR or VARCHAR.
Read more >
mne_bids.write — MNE-BIDS 0.11.1 documentation
The sidecar json file provides meta data about the data of a certain datatype. Parameters ---------- raw : mne.io.Raw The data as MNE-Python ......
Read more >
Common transfer file: CTF 22 specification - GOV.UK
This document will enable the suppliers of management information systems (MIS) to schools to develop their software to generate and export CTFs ...
Read more >
Common Transfer Files - Importing and Exporting - Osmis
Each transfer file contains details of the pupil/students being transferred (such as their contacts, attendance history, assessment data, etc.), as well as ...
Read more >
2019 Defcon DFIR CTF Write-up - Jai Minton
The Unofficial Defcon DFIR CTF comprised of 5 different challenge ... sys from binascii import unhexlify from datetime import datetime, ...
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