0

I want to show the createtable time of mysql table:

I run this in mysql console

MariaDB [Restaurant]> select CREATE_TIME from information_schema.tables where table_name = 'mytalbe';

+---------------------+ | CREATE_TIME | +---------------------+ | 2016-06-02 15:38:02 | | NULL | +---------------------+

But I run this sentence under python, it goes wrong:

sql='select CREATE_TIME from information_schema.tables where table_name = %s;'
value=('mytalbe',)
result=cur.execute(sql,value)

It throws an exception as:

Warning: Can't find file:'./performance_schema/mytalbe.frm'(errno:13) result=cur.execute(sql,value)

What should I do to get the right result as in mysql? Thanks very much!

kot-da-vinci
  • 1,152
  • 16
  • 30
mengyeer
  • 3
  • 4
  • 1
    its permission error see [here](http://stackoverflow.com/questions/6443428/cant-find-file-ci-users-frm-errno-13). – shivsn Jun 10 '16 at 08:05
  • but I do not have the root permission of the server. I can not read the performance_schema file using my account, what should I do? – mengyeer Jun 10 '16 at 08:58
  • But in mysql the sentence runs successful. why this happen? – mengyeer Jun 10 '16 at 08:58
  • try a simple query like `select * from tablename ` check if results are coming. – shivsn Jun 10 '16 at 08:59
  • 'select * from tablename', this sentence runs successful both in python and mysql – mengyeer Jun 10 '16 at 09:00
  • why don't you specify the table name in query itself instead of using value. – shivsn Jun 10 '16 at 09:02
  • since I want to separate variable from sql sentence. And this sentence is wrong in mysql :select CREATE_TIME from information_schema.tables where table_name = mytalbe; – mengyeer Jun 10 '16 at 09:08
  • Do `select USER()` when you are logged into console and via python. Permissions can depend on both username and hostname. – Solarflare Jun 10 '16 at 10:27
  • Yes!! select user() works. Could you tell me why this works? – mengyeer Jun 10 '16 at 12:01

0 Answers0