I know it s been here a lot of times but I didn t find the right answer for my case.
First: I m making an easy database system (for myself) that will run with no hashes etc. (for now at least). Now I got stuck.
import sys
import os
filename = ""
database = ""
path = ""
table = ""
class Nollty:
returns = 0
errors = 0
def __init__(self, filename, database):
self.filename = filename
self.database = database
self.path = self.filename + "databases/" + self.database
openfile = open(self.path + "/db_required", "r")
if not openfile.errors:
self.returns = 1
if not os.path.exists(self.path + "/db_required"):
self.returns = 0
openfile.close();
def select(self, table):
errors = 0
self.table = table
openfile = open(self.path + "/" + self.table, "r")
if not openfile.errors:
errors = 1
if not os.path.exists(self.path + "/" + self.table):
errors = 0
openfile.close();
nollty = Nollty("", "test")
if nollty.returns == 1:
print "Successfully connected to the database!"
query = nollty.select("aaa_auto")
if query.errors == 0:
print "Successfully chosen the table!"
错误产出是:
Traceback (most recent call last):
File "/home/spotrudloff/Python/Nollty/nollty.py", line 40, in <module>
if query.errors == 0:
AttributeError: NoneType object has no attribute errors
问题很可能是Im PHP方案管理员,今天,我几小时学会了Thury(因此我的想法仍然是“Py”。)
Thanks for all the responses.