| 166 | | from django.core import db |
|---|
| 167 | | |
|---|
| 168 | | # Get the sql file name for the init data for the current database engine |
|---|
| 169 | | db_engine_sql_file_name = os.path.join(app_dir, opts.module_name + '.' + db.DATABASE_ENGINE.lower() + '.sql') |
|---|
| 170 | | |
|---|
| 171 | | # Check if the data specific file exists |
|---|
| 172 | | if os.path.exists(db_engine_sql_file_name): |
|---|
| 173 | | sql_file_name = db_engine_sql_file_name |
|---|
| 174 | | # if the database specific file doesn't exist, use the database agnostic version |
|---|
| 175 | | else: |
|---|
| 176 | | sql_file_name = os.path.join(app_dir, opts.module_name + '.sql') |
|---|
| 177 | | |
|---|
| 178 | | if os.path.exists(sql_file_name): |
|---|
| 179 | | fp = open(sql_file_name, 'r') |
|---|
| 180 | | output.append(fp.read()) |
|---|
| 181 | | fp.close() |
|---|
| | 168 | sql_files = [os.path.join(app_dir, opts.module_name + '.' + db.DATABASE_ENGINE + '.sql'), |
|---|
| | 169 | os.path.join(app_dir, opts.module_name + '.sql')] |
|---|
| | 170 | for sql_file in sql_files: |
|---|
| | 171 | if os.path.exists(sql_file): |
|---|
| | 172 | fp = open(sql_file) |
|---|
| | 173 | output.append(fp.read()) |
|---|
| | 174 | fp.close() |
|---|
| | 175 | |
|---|