Skip to content
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

Converting timestamp in mysql to postgres #1

Open
mark-ellul opened this issue Jun 8, 2020 · 1 comment
Open

Converting timestamp in mysql to postgres #1

mark-ellul opened this issue Jun 8, 2020 · 1 comment

Comments

@mark-ellul
Copy link

mark-ellul commented Jun 8, 2020

Hi,

Is there a way I can alter the table conversion, this error occurred because the mysql table has a datetime, or fix this issue (below)?

Regards

Mark

LINE 10:  created_at DATETIME NOT NULL, 
                     ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/mark/opt/anaconda3/envs/dyn/bin/sqlacrossover", line 8, in <module>
    sys.exit(main())
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlacrossover.py", line 177, in main
    target.create_all(source.meta)
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlacrossover.py", line 44, in create_all
    metadata.create_all(self.engine)
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/sql/schema.py", line 4465, in create_all
    ddl.SchemaGenerator, self, checkfirst=checkfirst, tables=tables
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2104, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1663, in _run_visitor
    visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/sql/visitors.py", line 144, in traverse_single
    return meth(obj, **kw)
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/sql/ddl.py", line 787, in visit_metadata
    _is_metadata_operation=True,
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/sql/visitors.py", line 144, in traverse_single
    return meth(obj, **kw)
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/sql/ddl.py", line 832, in visit_table
    include_foreign_key_constraints,  # noqa
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1020, in execute
    return meth(self, multiparams, params)
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/sql/ddl.py", line 72, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1082, in _execute_ddl
    compiled,
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1324, in _execute_context
    e, statement, parameters, cursor, context
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1518, in _handle_dbapi_exception
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1284, in _execute_context
    cursor, statement, parameters, context
  File "/Users/mark/opt/anaconda3/envs/dyn/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 590, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedObject) type "datetime" does not exist
LINE 10:  created_at DATETIME NOT NULL, 
                     ^

[SQL: 
CREATE TABLE account_vetos (
	id SERIAL NOT NULL, 
	email_address VARCHAR(255), 
	reason TEXT, 
	status INTEGER, 
	notes TEXT, 
	origin VARCHAR(255), 
	site_id INTEGER, 
	created_at DATETIME NOT NULL, 
	updated_at DATETIME NOT NULL, 
	PRIMARY KEY (id)
)

]
(Background on this error at: http://sqlalche.me/e/f405)
@mark-ellul
Copy link
Author

CREATE TABLE account_vetos (
id int(11) NOT NULL AUTO_INCREMENT,
email_address varchar(255) DEFAULT NULL,
reason text,
status int(11) DEFAULT NULL,
notes text,
origin varchar(255) DEFAULT NULL,
site_id int(11) DEFAULT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=710 DEFAULT CHARSET=utf8;

is the mysql table... when it tries to create it in postgresql it tries to use a datetime.

Are there any changes I can make to this project to make it work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant